美文网首页
css(1):not()和last-child

css(1):not()和last-child

作者: kkkkkkee | 来源:发表于2020-07-29 17:38 被阅读0次

1.last-child

    .ul li {    
         border: 1px solid red;
    }
    .ul li:last-child {    
         border: none;  
     }

ul最后一个li元素无边框。

2.:not()

    .ul li:not(:last-child) {    
         border: 1px solid red;
     }

ul最后一个li元素无边框。

两种作用一样的样式写法,第二种更语义化一些。

相关文章

网友评论

      本文标题:css(1):not()和last-child

      本文链接:https://www.haomeiwen.com/subject/lxlkrktx.html