CSS :not() 偽類
- 上一頁 :modal
- 下一頁 :nth-child()
- 返回上一層 CSS 偽類參考手冊
定義和用法
CSS :not()
偽類用于匹配任何不是指定元素/選擇器的元素。
實例
例子 1
為所有不是 <p> 元素的元素設置文本顏色:
:not(p) { color: red; }
例子 2
更多使用 :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; }
CSS 語法
:not(selector) { css declarations; }
技術細節
版本: | CSS3 |
---|
瀏覽器支持
表格中的數字指定了完全支持該偽類的首個瀏覽器版本。
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
4.0 | 9.0 | 3.5 | 3.2 | 9.6 |
- 上一頁 :modal
- 下一頁 :nth-child()
- 返回上一層 CSS 偽類參考手冊