<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <style type="text/css">
            .container{
                display: flex;
                flex-wrap: wrap;
            }
            .list{
                width: 24%;
                height: 100px;
                background-color: aqua;
                margin-top: 10px;
            }
            .list:not(:nth-child(4n)){
                margin-right: calc(4%/3);
            }
        </style>
    </head>
    <body>
        <div class="container">
            <div class="list"></div>
            <div class="list"></div>
            <div class="list"></div>
            <div class="list"></div>
            <div class="list"></div>
            <div class="list"></div>
            <div class="list"></div>
            <div class="list"></div>
            <div class="list"></div>
        </div>
        <script type="text/javascript">
            
        </script>
    </body>
</html>

2023-05-16T15:34:03.png
转载
css 一行展示4个元素,不足的左对齐 - Name张三 - 博客园
https://www.cnblogs.com/987364-wu/p/16375249.html