:not(selector) 比如:假设我想选择所有 div,除了 id 为 的那个 container。下面代码: div:not(#container){color:blue; } 否定伪类:not()的几个特点: :not()的优先级是 0,因为它的优先级是由括号里面的参数来定的; :not()伪类可以同时判断多个选择器,比如input:not(:disabled):not(:read-only) {},表...
:not(selector) :not(p) 选择非 selector 元素的元素(即反选) ::selection ::selection{color: red} 选择光标选中的文字 :enabled 【主要用于表单元素】input[type="text"]:enabled 选择器匹配每个启用的的元素 :disabled 【主要用于表单元素】input[type="text"]:disabled 选择器匹配每个禁用的的元素 :checke...
:not(selector):选取不符合括号内选择器的所有元素。 示例:将不是段落的元素的背景色改为灰色: *:not(p) { background-color: gray; } 4、常见应用 设置鼠标悬停在元素上时的样式; 为已访问和未访问链接设置不同的样式; 设置元素获得焦点时的样式; // 示例:a 标签的四种状态,分别对应 4 种伪类; /* ...
:not(selector) 比如:假设我想选择所有 div,除了 id 为 的那个 container。下面代码: div:not(#container){color:blue;} 否定伪类:not()的几个特点: :not()的优先级是 0,因为它的优先级是由括号里面的参数来定的; :not()伪类可以同时判断多个选择器,比如input:not(:disabled):not(:read-only) {},表示...
:not(selector) :not§ 选择每个非 <p> 元素的元素。 :nth-child(n) p:nth-child(2) 选择作为其父的第二个子元素的每个 <p> 元素。 :nth-last-child(n) p:nth-last-child(2) 选择作为父的第二个子元素的每个<p>元素,从最后一个子元素计数。 :nth-last-of-type(n) p:nth-last-of-type(2...
p:empty选择没有子元素的每个<p>元素(包括文本节点)。 :not(selector) :not(p)选择非<p>元素的每个元素。 input状态选择器 :focus获得焦点的 input 元素 :enabled每个启用的 input 元素 :disabled每个禁用的 input 元素 :checked每个被选中的 input 元素...
(1):nth-last-child(1)| | E:only-of-type | 匹配父元素下使用同种标签的唯一一个子元素,等同于:first-of-type:last-of-type或 :nth-of-type(1):nth-last-of-type(1)| | E:empty | 匹配一个不包含任何子元素的元素,文本节点也被看作子元素| | E:not(selector) | 匹配不符合当前选择器的...
因为老是将这两个的not方法弄混,所以写一下备忘。 css中:not()选择器用法 :not 伪类选择器可以筛选不符合表达式的元素,:not(selector)其中的selector为css选择器 ul li:not(:first-child) ul li:not(.text) //不包含class="text"的元素 :not(p) //非段落元素 ...
中的位置匹配元素:nth-last-of-type(n) 匹配给定类型的元素,基于它们在一组兄弟元素中的位置,从末尾开始计数:last-child 表示一组兄弟元素中的最后一个元素:root 设置HTML文档:empty 指定空的元素:enabled 选择可用元素:disabled 选择被禁用元素:checked 选择选中的元素:not(selector) 选择与 <selector> 不匹配...
:enabled input:enabled 选择每个启用的 <input> 元素。 :disabled input:disabled 选择每个禁用的 <input> 元素 :checked input:checked 选择每个被选中的 <input> 元素。 :not(selector) :not(p) 选择非 <p> 元素的每个元素。 ::selection ::selection 选择被用户选取的元素部分。