否定选择器(Negation Selector) 选取不匹配特定选择器的元素。 否定选择器(:not())用于排除某些元素,即选择除特定元素外的所有其他元素。让我们通过一个实际的例子来说明如何使用否定选择器: 假设我们有以下HTML代码,表示一个列表,其中有一些项目被标记为特殊项目: <ul> <li>Item 1</li> <li class="special">...
Type Selector Universal Selector Attribute Selector Class Selector ID Selector Pseudo-class /* Type */h1{}/* Universal */*{}/* Attribute */a[title]{}/* Class */.parent{}/* ID */#demo{}/* Pseudo-class */:first-child{}
p:empty选择没有子元素的每个<p>元素(包括文本节点)。 :not(selector) :not(p)选择非<p>元素的每个元素。 input状态选择器 :focus获得焦点的 input 元素 :enabled每个启用的 input 元素 :disabled每个禁用的 input 元素 :checked每个被选中的 input 元素...
4.4、否定伪类:将匹配的元素排除在外 语法::not(selector); 5、伪元素选择器 5.1、::first-letter 获取匹配元素的第一个字母(字符) 5.2、::first-line 获取匹配元素的首行 5.3、::selection 匹配用户选取的部分 注意:W3C规定所有的伪类选择器全部使用一个冒号,在CSS3中,所有的伪元素选择器,全部使用两个冒号。
Css Selector使用方法 ①css selector定位不支持角标定位 ②input标签选择器,定位到HTML中所有的Input标签 ③div.inner通过定位div标签,再在div标签中查找class为inner的元素 ④input#i1 先定位到Input标签,再在input标签中查找id为i1的元素 1.css selector支持id,class定位 ...
:not(selector) :not(p) 选择非 selector 元素的元素(即反选) ::selection ::selection{color: red} 选择光标选中的文字 :enabled 【主要用于表单元素】input[type="text"]:enabled 选择器匹配每个启用的的元素 :disabled 【主要用于表单元素】input[type="text"]:disabled 选择器匹配每个禁用的的元素 :checke...
属性选择器(Attribute Selector):通过元素的属性选择 HTML 元素。属性选择器可以根据属性名和属性值进行选择。 如下代码,input[type="text"]选择器将选择所有type属性为"text"的 <input> 元素。 input[type="text"]{border:1pxsolid gray;} 后代选择器(Descendant Selector):通过指定元素的后代关系选择 HTML 元素...
class selector: .classname ID selector: #idName universal selector: * ns|* *|* attribute selector [attr=value] Combinators adjacent sibling selectors A+B General sibling selectors A~B Child selectors A>B Descendant Selectors A B Pseudo-elements ...
:enabled input:enabled 选择每个启用的 <input> 元素。 :disabled input:disabled 选择每个禁用的 <input> 元素 :checked input:checked 选择每个被选中的 <input> 元素。 :not(selector) :not(p) 选择非 <p> 元素的每个元素。 ::selection ::selection 选择被用户选取的元素部分。
The[attribute*="value"]selector is used to select elements whose attribute value contains a specified value. The following example selects all elements with a class attribute value that contains "te": Note:The value does not have to be a whole word!