html - :not selector in css not working

标签 html css

请引用下面的代码

html:

<a href="#" class="red">AA</a>
<a href="#" class="navitem dropdown-toggle">BB</a>
<a href="#" class="user-nav">CC</a>
<a href="#">DD</a>

我想应用除了包含以下类的两个 anchor 之外的颜色“navitem dropdown-toggle”和“user-nav”

CSS:

:not(a[class="navitem dropdown-toggle"]), :not(a[class="user-nav"]) {
    color:#C71444 !important;
    text-decoration:none !important;
}

但颜色不适用于第一个和最后一个 anchor 标记。没有任何效果。为什么?

fiddle :http://jsfiddle.net/QymZq/1/

谢谢,

湿婆

最佳答案

不完全相同,但它可以完成工作

a:not(.navitem):not(.user-nav):not(.dropdown-toggle) {
    color:#C71444 !important;
    text-decoration:none !important;
}

但是尽量避免 :not 因为它是性能 killer 。

DEMO HERE

关于html - :not selector in css not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21628843/

相关文章:

javascript - 在文本框中按 Enter 后,重定向到 newtab url - 绕过 Firefox 弹出窗口阻止

javascript - jQuery 获取某个类的页面上每个 div 的高度

html - CSS 下拉导航更改悬停颜色

html - CSS HTML强制表列到特定大小

html - 如何防止 li 文本进入按钮下方

html - 简单的非滚动背景图像

html - 让我的下拉列表下降 "up"

html - 如何让 col-md-* 在手机屏幕上按照我想要的方式工作?

ios - JQuery Mobile : Extra space, 黑线出现在数据角色 ="content"下?

javascript - jquery 简单的 ul li 内容 slider