CSS 中的 :not 伪类

用:Not选择与特定选择符不匹配的元素。将Simple selector作为参数提供给:Not,则所有不匹配的元素都将被选中。

第一个示例将选择没有第一个PAR类的所有p个元素:

1p:not(.first-par) {
2  background-color: #E4AF4C;
3}

在第二个示例中,我们为未组织列表(Ul)中的所有列表项(Li)选择::BEFORE伪元素,该列表的ID不是toc,也不是in-list的类:

1ul:not(#toc, .in-list) li::before {
2  /* Something stylish */
3}

在第三个示例中,我们选择了文章元素中不是跨距的所有内容:

1article *:not(span) {
2  color: cornsilk;
3}

👉:所有现代浏览器都不支持。

Published At
Categories with 技术
Tagged with
comments powered by Disqus