flex布局,设置一行显示个数

  • Post author:
  • Post category:其他


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        #box{
            display: flex;
            flex-flow: wrap;
            width: 800px;
            height: 360px;
            border: 1px solid #ccc;
        }
        .item{
            width: 150px;
            height: 120px;
            background: red;
        }

        #boxs{
            display: flex;
            flex-flow: wrap;
            width: 800px;
            height: 360px;
            border: 1px solid #ccc;
        }
        .items{
            width: 20%;
            /*height: 120px;*/
            background: red;
            padding: 0px 10px;
            box-sizing: border-box;
            /*margin: 0 10px;*/
            border: 1px solid #ccc;
            /*flex: 1;*/
        }
    </style>
    <script>
    </script>
</head>
<body>
    <div id="box">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
        <div class="item">4</div>
        <div class="item">5</div>
        <div class="item">6</div>
        <div class="item">7</div>
        <div class="item">8</div>
        <div class="item">9</div>
        <div class="item">10</div>
        <div class="item">11</div>
    </div>

    <div id="boxs">
        <div class="items">1</div>
        <div class="items">2</div>
        <div class="items">3</div>
        <div class="items">4</div>
        <div class="items">5</div>
        <div class="items">6</div>
        <div class="items">7</div>
    </div>
</body>
</html>



版权声明:本文为leixu1027原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。