:nth-child选择器、:nth-child(n)选择器、:nth-last-child(n)选择器、:nth-of-type(n)选择器、 :empty选择器、:target选择器。 这些基本上都很常用,今天着重说下:否定伪类:not() 否定伪类特别有用,在css中, :not选择器 用于匹配非指定元素/选择器的每个元素,语法格式: :not(selector) 比如:假设我想选...
3):nth-child(n):选取父元素中第n个子元素。 示例:将列表中的奇数位置的项目的背景色改为蓝色: li:nth-child(odd) { background-color: blue; } 3.4否定伪类选择器 这类选择器用于排除符合特定条件的元素。例如: :not(selector):选取不符合括号内选择器的所有元素。 示例:将不是段落的元素的背景色改为...
css中:not()选择器用法 :not 伪类选择器可以筛选不符合表达式的元素,:not(selector)其中的selector为css选择器 ul li:not(:first-child) ul li:not(.text) //不包含class="text"的元素 :not(p) //非段落元素 ul li:not(:first-child):not(:last-child) //not可叠加使用 jQuery中.not()方法 not(...
方法1:使用伪类选择器:not <style>dom div:not(:first-child){background:red;}</style> 说明::not(selector) 选择器匹配非指定元素/选择器的每个元素。:first-child 选择器用于选取属于其父元素的首个子元素的指定选择器。方法2:使用nth-of-type或者nth-child <style>dom div:nth-of-type(n...
:first-child、:last-child、:nth-child(n):、:nth-last-child(n)这几个用来根据元素的排序选中制定位置的元素,最常用的就是在制作表格时,可以通过:nth-child(2n)来实现表格的着色显示,便于用户观察同一行的数据。 :not(selector) 是用来反选的,用来选择不匹配的制定选择器的第一个元素,这个实际应用中我还...
:root选择器、:not选择器、:only-child选择器、:first-child选择器、:last-child选择器、 :nth-child选择器、:nth-child(n)选择器、:nth-last-child(n)选择器、:nth-of-type(n)选择器、 :empty选择器、:target选择器。 这些基本上都很常用,今天着重说下:否定伪类:not() ...
4.3.4、:only-child 匹配属于其父元素中的唯一子元素 4.3.5、:nth-child(n)匹配属于其父元素中的第n个子元素 4.4、否定伪类:将匹配的元素排除在外 语法::not(selector); 5、伪元素选择器 5.1、::first-letter 获取匹配元素的第一个字母(字符)
p::nth-last-child(n)同上,从最后一个子元素开始计数。 :empty p:empty选择没有子元素的每个<p>元素(包括文本节点)。 :not(selector) :not(p)选择非<p>元素的每个元素。 input状态选择器 :focus获得焦点的 input 元素 :enabled每个启用的 input 元素 ...
选择属性值以特定值结尾的元素:如p[spec&='len2']选择spec属性值以len2结尾的元素。伪类选择器:如p:nthchild选择第一个p元素,p:nthlastchild选择倒数第一个p元素。CSS Selector提供了一种灵活且强大的方式来定位网页中的元素,广泛应用于网页开发、测试和自动化脚本中。