flex布局最后一行左对齐最佳解决方案

2022-03-09 08:16:18 浏览数 (1)

如图一行显示6个

代码语言:javascript复制
<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <style>
        .parent {
            width: 400px;
            height: 300px;
            display: flex;
            justify-content: space-between;
            align-content: flex-start;
            flex-flow: row wrap;
            border: 1px solid;
        }

        .parent>i {
            width: 14.5%;
        }

        .child {
            width: 14.5%;
            height: 60px;
            box-sizing: border-box;
            background-color: skyblue;
            margin-bottom: 20px;

            display: flex;
            align-items: center;
            justify-content: center;
        }
    </style>
</head>

<body>
    <div class="parent">
        <div class="child">a</div>
        <div class="child">a</div>
        <div class="child">a</div>
        <div class="child">a</div>
        <div class="child">a</div>
        <div class="child">a</div>
        <div class="child">a</div>
        <div class="child">a</div>
        <div class="child">a</div>
        <div class="child">a</div>
        <div class="child">a</div>
        <div class="child">a</div>
        <div class="child">a</div>
        <div class="child">a</div>
        <div class="child">a</div>
        <div class="child">a</div>
        <i></i><i></i><i></i><i></i><i></i><i></i>
    </div>

</body>

</html>

0 人点赞