简体   繁体   English

CSS:“属性选择器”和“ not()”在一起

[英]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-' ". 我想要一个更通用的规则,指定“样式必须应用于所有不具有以'ui-'开头的类名的A标记”。

So, I should "merge" this kinf of definition [class*='ui-'] with not() . 因此,我应该用not() “合并”定义[class*='ui-']

Is possible in some way? 有可能吗? Thank you. 谢谢。

Yes, it's possible, just put [class*='ui-'] inside a not() . 是的,有可能,只需将[class*='ui-']放入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 演示版

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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