1、:first-of-type选择所设置元素的第一个原色
//选择第一个p标签
p:first-of-type{
}
2、:last-of-type选择所设置元素的最后一个
//选择最后一个p元素
p:last-of-type{
}
3、:nth-of-type设置所选元素的第几个元素
//选择第二个p标签
p:nth-of-type(2){
}
4、nth-last-of-type()设置倒数第几个元素的样式
//选择元素倒数第二个
p:nth-last-of-type(2){
}
5、:first-child选择第一个子元素
6、:last-child选择最后一个子元素
7、:nth-child()从正序开始选择第几个元素
8、:nth-last-child()从倒叙选择第几个元素
9、::selected选择用户鼠标选中内容的选择器
p::selected{
background:red;
}
10、:not选择非用户指定内容的选择器
body:not(p){
background:red;//body标签下除了p标签所有的标签背景颜色都是红色
}
11、:root根节点选择器
:root{
background:red;//所有的元素都变成红色
}
12、:enabled选择状态可用的元素(input、button) :enabled
input[type="text"]:enabled{
}
//所有type=text的input并且该input处于enabled状态都会受到影响
13、:disabled选择状态不可用的元素(input、button)
:disabled
14、:checked选择状态下的input标签
:checked
15、属性选择器 [attr=“value”]
input[type="text"]{
}
//所有type=text的input元素都会发生变化
16、target选择器选择当前活动的id锚点