更多的选择器
更多伪类选择器
:first-child
选中第一个子元素
:first-of-type
/* 选中a元素,并且a元素是第一个子元素 */
a:first-child{
color: red;
}
/* 选中的是子元素的第一个a元素 */
a:first-of-type{
color:blue;
}
:last-child
选中最后一个子元素
:nth-child
选中指定的第几个子元素
even关键字=2n 第偶数个被选中
2n+1 = odd 第奇数个被选中
:nth-of-type
选中指定的子元素中第几个某类型元素。
更多伪元素选择器
::first-letter
选中元素中第一个字母。
::first-line
选中元素中第一行的文字。
selection
选中被用户框选的文字。
转载请注明原文地址: https://mac.8miu.com/read-484292.html