我想将 css 应用于所有以“abcd-”开头的类,但我不想将该 css 应用于名称为“abcd-dontapply”的类。我可以这样做吗?
我尝试过的
a[class |= "abcd"] :not([class = "abcd-dontapply"])
{
---define CSS
}
但这不起作用,它没有将 CSS 应用于任何以“abcd-”开头的类。
最佳答案
如您的问题所述:
Don't add whitespace unnecessarily. The whitespace just before the :not is significant, i.e. it changes the meaning of the selector.
a[class^="abcd"]:not(.abcd-dontapply)
{
/* define CSS here*/
}
您可以找到所有属性选择器规范 here .
关于CSS 属性选择器类以但不等于,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32637589/