请引用下面的代码
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 。
关于html - :not selector in css not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21628843/