导航
×
   ❮   
HTML CSS JavaScript PHP Go Sass W3C Colors ECMS

CSS :not() 伪类


实例

为所有非<p> 元素的元素设置文本颜色

:not(p) {
  color: red;
}
亲自试一试 »

更多“自己尝试”的例子见下文。


定义和用法

: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;
}
亲自试一试 »

Copyright ©2020-2026 freew3c.com All Rights Reserved 提供的内容仅用于学习和测试,不保证内容的正确性。