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;
            width:530px;
            font-size:0;
        }
        a{
            text-decoration: none;
            display: inline-block;
            width: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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值