删除:悬停在媒体样式表上? [英] Remove a:hover on a media stylesheet?

查看:207
本文介绍了删除:悬停在媒体样式表上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在媒体查询CSS文件中删除主CSS文件中声明的样式条目?



例如,我要删除a:hover entry用于触摸设备。



main.css: a:hover {color:#999999;背景:#111111;}



如何在media.css中取消?

$



要使规则仅在媒体查询不满足时应用的唯一方法是在查询的否定版本中隔离它,可以在 @media 在您的main.css样式表内阻止:

  @media not [您的媒体查询] {
a :hover {color:#999999; background:#111111;}
}

 < link rel =stylesheetmedia =allhref =main.css> 
< link rel =stylesheetmedia =[您的媒体查询]href =media.css>

<! - 或者把它放在一个单独的文件中,并链接到上面 - >
< style media =not [您的媒体查询]>
a:hover {color:#999999; background:#111111;}
< / style>

或者,您可以撤消media.css样式表中的样式,但缺点是您必须






1 除了在桌面浏览器中开发人员工具,也许。


How can I delete a style entry stated in the main CSS-file in a media query CSS-file?

For example, I'd like to delete the a:hover entry for use on touch devices.

main.css: a:hover {color:#999999; background:#111111;}

How can I cancel this out in the media.css?

解决方案

You can't "delete" CSS rules.1 The cascade doesn't work that way.

The only way to get your rule to apply only when the media query isn't satisfied is to isolate it in a negated version of the query, either in a @media block within your main.css stylesheet:

@media not [your media query] {
    a:hover {color:#999999; background:#111111;}
}

Or in a separate stylesheet within your page head:

<link rel="stylesheet" media="all" href="main.css">
<link rel="stylesheet" media="[your media query]" href="media.css">

<!-- Or put this in a separate file and link to it as above -->
<style media="not [your media query]">
a:hover {color:#999999; background:#111111;}
</style>

Alternatively you can undo the styles within your media.css stylesheet, but the downside to that is you must know what values to fall back to.


1 Except in a desktop browser's developer tools, maybe.

这篇关于删除:悬停在媒体样式表上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆