flex之网页的伸缩布局小案例

2019-06-27  本文已影响0人  小透明进击战
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        .box {
            height: 700px;
            width: 500px;
            display: flex;
            background-color: #eeeeee;
            margin: 100px auto;
            /*主轴默认为row,所以要改变主轴*/
            flex-direction: column;

        }
        header {
            width: 100%;
            height: 50px;
            background-color: pink;
        }
        footer {
            width: 100%;
            height: 50px;
            background-color: hotpink;
        }
        main {
            width: 100%;

            background-color: lightgreen;
            flex: 1;
            display: flex;
        }
        main > article {

            height: 100%;
            flex: 1;
            background-color: cornflowerblue;
        }
        main > aside {

            height: 100%;
            flex: 3;
            background-color: greenyellow;
        }


    </style>
</head>
<body>
<div class="box">
    <header></header>
    <main>
        <article></article>
        <aside></aside>
    </main>
    <footer></footer>

</div>

</body>
</html>
上一篇下一篇

猜你喜欢

热点阅读