html - 在 :not pseudo class 中使用 "absolute"css 路径

标签 html css

当我在 :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;
}

http://jsfiddle.net/2a3mzn68/1/

最佳答案

在最新版本的 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/

相关文章:

html - Div 幻灯片不显示

html - css类无法访问它

javascript - 单击一个元素以删除其他元素类

html - div 的内容没有响应

html - Bootstrap 嵌套列利用推/拉

html - Bootstrap col-md 剪切标签的文字

javascript - JavaScript 中图像的相对路径

c# - 无法在虚拟目录中使用 MVC2 在 Site.Master 中正确引用 CSS

css - 无法将页脚放在正确的位置 - chalice 布局 - 引导网格

html - 如何在React中分离文件的CSS规则?