[英]CSS: Deny Attribute Selector
I want to add a border to every div that doesn't have the bar class: 我想为每个没有bar类的div添加边框:
HTML 的HTML
<div class="foo bar">010101</div>
<div class="foo">010101</div>
<div class="foo bar">010101</div>
<div class="foo">010101</div>
<div>010101</div>
CSS 的CSS
div {
background: #ffcc00;
height: 50%;
margin: 10px 0;
padding: 10px;
width: 50%;
}
Elements with bar class should not be styled. 带有bar类的元素不应设置样式。 I need to use some attribute selector.
我需要使用一些属性选择器。 Are there any attribute selector to do that?
是否有任何属性选择器可以做到这一点?
UPDATE: 更新:
Fixed using :not() In my case: "div:not(.bar) {" 在我的情况下使用:not()修复:“ div:not(.bar){”
Thanks. 谢谢。
Try this out: 试试看:
div[class!="bar"] {
//CSS HERE
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.