百分比布局实现div自动换行

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        .allBox {
            width: 60%;
            display: flex;
            flex-wrap: wrap; /*只需要写这行样式就可以实现div自动换行了*/
        }
        .allBox .con {
            width: 30%;
            background-color: green;
            height: 110px;
            border-radius: 20px;
            margin: 20px;
            display: flex;  /*实现div里面的内容居中*/
            justify-content: center; /*实现div里面的内容居中*/
            align-items: center; /*实现div里面的内容居中*/
        }
    </style>
</head>
<body>
    <div class="allBox">
        <div class="con">这是个寂寞的天</div>
        <div class="con">这是个寂寞的天</div>
        <div class="con">这是个寂寞的天</div>
        <div class="con">这是个寂寞的天</div>
        <div class="con">这是个寂寞的天</div>
        <div class="con">这是个寂寞的天</div>
        <div class="con">这是个寂寞的天</div>
        <div class="con">这是个寂寞的天</div>
        <div class="con">这是个寂寞的天</div>
        <div class="con">这是个寂寞的天</div>
        <div class="con">这是个寂寞的天</div>
        <div class="con">这是个寂寞的天</div>
        <div class="con">这是个寂寞的天</div>
    </div>
</body>
</html>

百分比布局实现div自动换行

上一篇:Redis入门不难系列(1)


下一篇:vue路由传值对象格式