CSS :not() 伪类
更多“自己尝试”的例子见下文。
定义和用法
:not()
伪类匹配所有不是指定元素/选择器的元素。
版本 | CSS3 |
---|
浏览器支持
表中数字表示该伪类完全支持的第一个浏览器版本。
伪类 | |||||
---|---|---|---|---|---|
:not() | 4.0 | 9.0 | 3.5 | 3.2 | 9.6 |
CSS 语法
:not(选择器) {
CSS 声明;
}
更多示例
示例
更多使用 not() 的示例
.special {
border: 2px solid maroon;
}
p:not(.special) {
color: green;
}
body :not(p) {
text-decoration: underline;
}
body :not(div):not(.special) {
font-weight: bold;
}
自己动手试一试 »