css - 无效的 CSS 选择器 :not()

标签 css css-selectors

我有这样的东西:

ul.select.open li:first-child:not(li ul) a

我在控制台上收到警告。为什么无效?它适用于我在我的网站上看到的内容,仅此而已,我将样式应用于第一个子列表 anchor ,但不应用于子子列表上的 anchor 。

我想了解为什么无效但仍然有效。

最佳答案

这是无效的,因为在 negation pseudo-class 中, :not(X), X 必须是简单选择器,ul li 不是。符合标准的浏览器需要忽略带有无效选择器的规则,因此如果该规则以某种方式起作用,则将其视为浏览器错误。

关于css - 无效的 CSS 选择器 :not(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19260609/

相关文章:

android - Jsoup : Select a row with class name containing whitespace at the end

css - 第 n 个 child 不响应类选择器

html - 列表项 anchor 中的 css3 第一个 child

css - 自托管字体在 Gatsby 和 Safari 中不起作用

html - 字体 "Myriad Pro"在 Chrome 中看起来很奇怪/模糊

html - 当屏幕尺寸较小时,第 n 个 child 不归因

css-selectors - 是否有一个 CSS 选择器可以选择带有溢出文本的元素?

html - 多个具有不同颜色的 href

javascript - 悬停时展开/折叠 div - 不活动时不折叠

html - 在 css 效果下创建一个新部分