1. .class 如.intro 选择所有class属性是 intro 的元素
2. #id 如#nn 选择所有id属性是 nn 的元素
3.element,element 如 div,p 选择所有的div元素和所有的p元素
4.element element 如 div p 选择所有div 里面的p元素,子元素,子子元素等都可以
5.element>element 如 div>p 选择所有div 里面的p子元素
6.element+element 如 div+p 选择所有div里面紧跟的p元素,如<div></div><p>test</p>
7.element~element 如 div~p 选择所有div里面跟着的p元素,不一定紧跟,如<div></div><span>你好</span><p>test</p>
8.[attribute] [target] 选择所有具有target属性的元素
9.[attribute=value] [target=_blank] 选择所有target 属性值是_blank 的元素
10.[attribute^=value] a[href^="https"] 选择所有包含href属性,且以https开头的<a>元素
11.[attribute$=value] a[href$=".pdf"] 选择所有包含href属性,且以.pdf结尾的<a>元素
12.[attribute*=value] a[href*="abc"] 选择所有包含href属性,且其值中包含abc 的<a>元素
13.:empty p:empty 选择所有没有子节点,包括文本的p元素
14.:first_child p:first_child 选择所有是其父元素第一个子元素的 p 元素
15:first_of_type p:first_of_type 选择所有是其父元素第一个p类型子元素的p 元素
16.last_of_type p:last_of_type 选择所有是其父元素最后一个p类型子元素的p元素
17.last_child p:last_child 选择所有是其父元素最后一个子元素的p元素
18.:not(selctor) :not(p) 选择所有不是p元素的元素
19.:nth_child(n) p:nth_child(2) 选择所有是其父元素第二个子元素的p元素
20.:nth_last_child(n) p:nth_last_child(2) 选择所有是其父元素倒数第二个子元素的p元素
21.nth_of_type(n) p:nth_of_type(2) 选择所有是其父元素第二个p类型子元素的p元素
22.nth_last_of_type(n) p:nth_last_of_type(2) 选择所有是其父元素倒数第二个p类型子元素的p元素
23.:only_child p:only_child 选择所有是其父元素唯一一个子元素的p元素
24.:only_of_type p:only_of_type 选择所有是其父元素唯一的一个p类型元素的子元素
© 著作权归作者所有
发表评论