否定伪类特别有用,在css中, :not选择器 用于匹配非指定元素/选择器的每个元素,语法格式: :not(selector) 比如:假设我想选择所有 div,除了 id 为 的那个 container。下面代码: div:not(#container){color:blue; } 否定伪类:not()的几个特点: :not()的优先级是 0,因为它的优先级是由括号里面的参数来定的...
在这些新选择器中,:not()是一个非常重要的成员,它允许我们排除某些元素,从而更加精确地应用样式。 :not()选择器的基本用法 :not()选择器的基本语法如下: element:not(selector) { /* 样式定义 */ } 这里,element是我们想要选择的基本元素,而selector则是我们想要排除的子元素。只有满足element但不满足selector...
selector:这是你想要排除的选择器。 1、排除特定类型的元素 body:not(p){color:blue;} 这段代码将为 body 元素内除了 p 元素之外的所有元素设置文本颜色为蓝色。 2、排除具有特定类的元素 div:not(.highlight){background-color:gray;} 这段代码将为 div 元素内不具有 highlight 类的所有元素设置背景颜色为...
:not(selector),参数selector为css中的选择器,可以是元素,类,id等。如不清楚,可以查阅CSS3 选择器了解详细。 语法 lineos:false 1 2 3 4 5 6 7 8 /*单个使用*/ :not(selector) { property: value; } /*多个使用*/ :not(selector1):not(selector2) { property: value; } 例子 下面代码,所有...
因为老是将这两个的not方法弄混,所以写一下备忘。 css中:not()选择器用法 :not 伪类选择器可以筛选不符合表达式的元素,:not(selector)其中的selector为css选择器 ul li:not(:first-child) ul li:not(.text) //不包含class="text"的元素 :not(p) //非段落元素 ...
否定伪类特别有用,在css中, :not选择器 用于匹配非指定元素/选择器的每个元素,语法格式: :not(selector) 比如:假设我想选择所有 div,除了 id 为 的那个 container。下面代码: div:not(#container){color:blue;} 否定伪类:not()的几个特点: :not()的优先级是 0,因为它的优先级是由括号里面的参数来定的;...
p:empty选择没有子元素的每个<p>元素(包括文本节点)。 :not(selector) :not(p)选择非<p>元素的每个元素。 input状态选择器 :focus获得焦点的 input 元素 :enabled每个启用的 input 元素 :disabled每个禁用的 input 元素 :checked每个被选中的 input 元素...
CSS :not Selector Instead of using 2 different selectors to assign styling and then another to negate it. Use the :not selector to select every element except those that match the argument you passed through 👍 /* ❌ */li{margin-left:10px;}li:first-of-type{margin-left:0;}/* ...
Environment Operating System: Darwin Node Version: v20.9.0 Nuxt Version: 3.9.1 CLI Version: 3.10.0 Nitro Version: 2.8.1 Package Manager: pnpm@8.10.4 Builder: - User Config: devtools Runtime Modules: - Build Modules: - Reproduction Not wo...
否定选择器(Negation Selector) 选取不匹配特定选择器的元素。 否定选择器(:not())用于排除某些元素,即选择除特定元素外的所有其他元素。让我们通过一个实际的例子来说明如何使用否定选择器: 假设我们有以下HTML代码,表示一个列表,其中有一些项目被标记为特殊项目: ...