CSS教程::nth-of-type()选择器

说明

nth-of-type(n) 选择器,匹配 同类型 中的 第n个 同级兄弟元素。

比 :nth-child() 选择器简单好理解

例子

选中 排在第 2 个位置,且是 ul 标签的元素

<style>
        ul:nth-of-type(2){
            color: red;
        }
</style>
<div class="box">
    <p>李雷</p>

    <p>韩梅梅</p>
</div>
<div>--------------------</div>
<p>lucy</p>

<p>lili</p>

运行结果:

解释:


原文出处:/show_1GWGMU3uWy3.html