使用flex布局(多行,一行三个),换行后最后一行左右对齐问题

<html>

<head>
    <style>
        html,
        body,
        ul {
            margin: 0;
            padding: 0;
        }

        ul {
            width: 100%;
            height: 40rem;
            background: #000;
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
        }

        li {
            width: 30%;
            height: 6rem;
            display: inline-block;
            background: #ededee;
            margin-top: 1rem;
            text-align: center;
        }

        ul:after {
            content: "";
            width: 30%;
            height: 0px;
            visibility: hidden;
        }
    </style>
</head>

<body>
    <ul>
        <li>1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
    </ul>
</body>

</html>

 

*重点在给外层的盒子加after

posted @ 2020-10-30 15:50  自律·给我自由  阅读(18161)  评论(0编辑  收藏  举报