简体   繁体   中英

CSS: “Attribute selector” and “not()” together

I have the following rule:

a:not(.ui-spinner-button):active 
{
  ...
}

I would like a more general rule specifying that "style must applied to all A tag that does NOT have a class name that begin with 'ui-' ".

So, I should "merge" this kinf of definition [class*='ui-'] with not() .

Is possible in some way? Thank you.

Yes, it's possible, just put [class*='ui-'] inside a not() .

a {
    color: cyan;
}

a:not([class*='ui-']) {
    color: pink;
}

<a class='ui-foobar'>ui-foobar</a>
<a class='foobar'>definitely not ui-foobar</a>

The first link will be cyan, the second one pink.

Demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM