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;
}
自己動手試一試 »