css3伪类选择器nth-of-type,:nth-last-of-type,:first-of-type,:last-of-type,:only-of-type

1, :nth-of-type(n) 匹配属于父元素的特定类型的第N个子元素

匹配结果:

2, :nth-last-of-type(n),匹配其父元素下的第N个特定类型的子元素,从后往前

满足条件:1,必须是特定类型    2,从后往前的第N个

3,:first-of-type 

4,  :last-of-type 匹配其父元素下的最后一个特定类型的子元素

         body div:last-of-type 满足条件,body下的所有DIV元素,最后一个DIV

5, :only-of-type 选择其父元素上的唯一一个相同类型的子元素

6, :empty()  空选择器

7, :not()  否定选择器

  

<nav>
        <a href="#">1</a>
        <a href="#">2</a>
        <a href="#">3</a>
        <a href="#">4</a>
        <a href="#">5</a>
    </nav>
 *{
           margin:0;
           padding:0;
       }
        nav{
            margin:0 auto;
            530px;
            font-size:0;
        }
        a{
            text-decoration: none;
            display: inline-block;
            100px;
            height:30px;
            line-height:30px;
            text-align: center;
            font-size:14px;
            margin-left:5px;

        }
        nav > a:not(:last-of-type){
            border-right:1px solid red;
        }

原文地址:https://www.cnblogs.com/xubj/p/10148660.html