首页 > 技术文章 > 弹性布局

reround 2019-04-17 16:16 原文

HTML部分:

        <div class="box">
            <div class="box-header">欢迎来到</div>
            <div class="box-content">
                <div>啦啦啦啦</div>
                <ul class="downla">
                    <li></li>
                    <li>绿</li>
                    <li></li>
                </ul>
                <div>哈哈哈哈</div>
            </div>
            <div class="box-footer">
                <ul>
                    <li></li>
                    <li></li>
                    <li></li>
                    <li></li>
                </ul>
            </div>
        </div>

CSS部分:

        *{
            margin: 0;
            padding: 0;
        }
        html,body,.box{
            height: 100%;
            min-width: 500px;
        }
        .box-header{
            height: 150px;
            line-height: 150px;
            background: #f60;
            text-align: center;
            font-size: 2rem;
            color: #fff;
        }
        .box{
            display: flex;
            flex-direction: column;
        }
        .box-content{
            flex: 1;
            font-size: 2rem;
            border: 1px solid greenyellow;
        }
        .downla{
            font-size: 3rem;
        }
        .box-footer{
            height: 150px;
            line-height: 150px;
            background: #f60;
            text-align: center;
            font-size: 2rem;
            color: #fff;
        }
        .box-footer ul{
            width: 100%;
            
        }
        .box-footer ul li{
            list-style: none;
            display: inline-block;
            width: 25%;
            float: left;
        }

最后在页面查看效果

推荐阅读