flex多栏布局

    <style>
        .container {
            width: 1200px;
            margin: 0 auto;
            display: flex;
        }
        
        .container>div {
            width: 380px;
            /* 也可以设置flex分配父容器宽度,再用padding设置相邻元素的间距 */
            height: 200px;
            /* 水平居中 */
            margin: 0 auto;
        }
        
        .container>div:first-of-type {
            background-color: red;
        }
        
        .container>div:nth-of-type(2) {
            background-color: green;
        }
        
        .container>div:last-of-type {
            background-color: blue;
        }
    </style>
    <div class="container">
        <div>第一列</div>
        <div>第二列</div>
        <div>第三列</div>
    </div>

 

posted on 2018-11-01 00:24  肥嘟嘟啊左卫门  阅读(103)  评论(0编辑  收藏  举报