更多的选择器
伪类选择器使用示例
例:
a:first-child {
color:red;
}
例:
p::selection {
background: #008c8c;
color: yellow;
}
更多伪类选择器
- first-child
选择第一个子元素
first-of-type,选中子元素中第一个指定类型的元素
-
last-child
-
nth-child
选中指定的第几个子元素
even:关键字,等同于2n
odd: 关键字,等同于2n+1
- nth-of-type
选中指定的子元素中第几个某类型的元素
更多的伪元素选择器
- first-letter
选中元素中的第一个字母
- first-line
选中元素中第一行的文字
- selection
选中被用户框选的文字