当我在 :not
伪选择器中放置“绝对”CSS 路径时,除了 Safari 之外,几乎所有浏览器都会忽略 CSS 规则。这是预期的行为吗?如何在不添加类或 ID 的情况下定位此特定元素?
HTML:
<body>
<header>
<h1>This one shouldn't be red</h1>
</header>
<h1>This one should be red</h1>
</body>
CSS:
h1:not(body > header > h1) {
color: red;
}
最佳答案
在最新版本的 Chrome (46.0.2490.80)、Firefox (41.0.2)、Opera (32.0) 和 Safari (9.0.1) 中,只有 Safari 支持 CSS4 Negation 伪类。 (根据 CSS4-selectors.com 处的浏览器 CSS-Selector)
在 CSS3 中,只允许一个简单的选择器作为 :not 的参数。
关于html - 在 :not pseudo class 中使用 "absolute"css 路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33378782/