CSS选择器:last-child
:first-child
li:first-child {
color: aquamarine;
}<body>
<li>我是第一个li元素,我能匹配,因为我是li元素并且是body下的第一个</li>
<li>我是第二个li元素</li>
<ul>
<li>我是第一个li元素, 我能匹配,因为我是ul下的第一个li</li>
<li>我是第二个li元素</li>
<li>我是第三个li元素</li>
</ul>
<li>我是第一个li元素</li>
<li>我是第二个li元素</li>
</body>:first-of-type
li:first-of-type {
color: blueviolet;
}:nth-of-type(n)
:nth-child(n)
:last-child
:last-of-type
:nth-last-of-type
:nth-last-child(n)
最后更新于