开发者

CSS: Deny Attribute Selector

开发者 https://www.devze.com 2023-03-25 16:59 出处:网络
I want to add a border to every div that doesn\'t have the bar class: HTML <div class=\"foo bar开发者_如何学运维\">010101</div>

I want to add a border to every div that doesn't have the bar class:

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

div {
    background: #ffcc00;
    height: 50%;
    margin: 10px 0;
    padding: 10px;
    width: 50%;
}

Elements with bar class should not be styled. 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) {"

Thanks.


Try this out:

div[class!="bar"] {
   //CSS HERE
}
0

精彩评论

暂无评论...
验证码 换一张
取 消