×

CSS中:not(:last-of-type)的作用

作者:abc1232018.03.01来源:Web前端之家浏览:14190评论:0
关键词:last-of-type

使用:not(:last-of-type)简单方便,再也不要麻烦的单独使用:last-of-type了,不错!
应用场景:平时我们的列表一般都会有分割线,但是最后一个列表没有分割线等。

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>CSS中:not(:last-of-type)的作用</title>
    </head>
    <style>
        
        .posts {
            list-style: none;
            width:400px;
            margin: 0;
            padding: 20px;
            margin: 4rem auto;
            background: #f00;
        }
        .posts li:not(:last-of-type){
            border-bottom: 1px solid #000;
            margin-bottom: .5rem;
            padding-bottom: .5rem;
        }
    </style>
    <body>
        <ul class="posts">
            <li>123123</li>
            <li>123123</li>
            <li>123123</li>
            <li>123123</li>
            <li>123123</li>
        </ul>
    </body>
</html>

您的支持是我们创作的动力!
温馨提示:本文作者系 ,经Web前端之家编辑修改或补充,转载请注明出处和本文链接:
https://www.jiangweishan.com/article/CSS11231231321231321.html

网友评论文明上网理性发言 已有0人参与

发表评论: