美文网首页工作生活
flex之伸缩网页

flex之伸缩网页

作者: 小透明进击战 | 来源:发表于2019-06-30 16:38 被阅读0次
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>猪猪旅行</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        header{
            width: 100%;
            display: flex;
        }
        header > a {
            flex: 1;
        }
        header > a > img {
            width: 100%;
        }
        main {
            margin: 10px auto;
            width: 100%;
            padding: 0 10px;
            box-sizing: border-box;

        }
        .item {
            width: 100%;
            height: 100px;
            margin-top: 10px;
            display: flex;
            background-color: dodgerblue;
            border-radius: 10px;
        }
        .item:nth-of-type(2) {
            background-color: deepskyblue;
        }
        .item:nth-of-type(3) {
            background-color: cornflowerblue;
        }
        .item:nth-of-type(4) {
            background-color: skyblue;
        }
        main > .item >.left {
            flex: 1;
        }
        main > .item > .right {
            flex: 2;
            /*设置换行显示,子元素的宽度之和必须大于父元素的宽*/
            flex-wrap: wrap;
            /*float的效果,flex可以做到*/
            display: flex;
        }
        .right > a {
            width: 50%;
            /*因为a是行内元素,所以要使它变成块元素*/
            display: block;
            text-align: center;
            line-height: 50px;
            text-decoration: none;
            color: #ffffff;
            border-bottom: 1px solid white;
            border-left: 1px solid white;
            box-sizing: border-box;
        }
        .right > a:nth-last-of-type(-n+2){
            border-bottom: none;
        }
        main > .extra {
            width: 100%;
            display: flex;
        }
        main > .extra > a {
            flex: 1;
        }
        main > .extra > a > img {
            width: 100%;
        }
        footer {
            width: 100%;
            font-size: 13px;
        }
        footer > nav {
            width: 100%;
            display: flex;
        }
        footer > nav > a {
            flex: 1;
            border-bottom: 1px solid #cccccc;
            border-top: 1px solid #cccccc;
            box-sizing: border-box;
            text-decoration: none;
            text-align: center;
            line-height: 30px;
            color: #999999;
        }
        footer > .link {
            text-align: center;
            line-height: 25px;
        }
        footer > .copyright {
            text-align: center;
        }
    </style>
</head>
<body>
<div class="container">
    <header>
        <a href="#">
            <img src="./images/banner.jpg" alt=""/>
        </a>
    </header>
    <main>
        <section class="item">
            <div class="left"></div>
            <div class="right">
                <a href="#">猪猪航班</a>
                <a href="#">猪猪酒店</a>
                <a href="#">猪猪团购</a>
                <a href="#">猪猪美食</a>
            </div>
        </section>
        <section class="item">
            <div class="left"></div>
            <div class="right">
                <a href="#">猪猪航班</a>
                <a href="#">猪猪酒店</a>
                <a href="#">猪猪团购</a>
                <a href="#">猪猪美食</a>
            </div>
        </section>
        <section class="item">
            <div class="left"></div>
            <div class="right">
                <a href="#">猪猪航班</a>
                <a href="#">猪猪酒店</a>
                <a href="#">猪猪团购</a>
                <a href="#">猪猪美食</a>
            </div>
        </section>
        <section class="item">
            <div class="left"></div>
            <div class="right">
                <a href="#">猪猪航班</a>
                <a href="#">猪猪酒店</a>
                <a href="#">猪猪团购</a>
                <a href="#">猪猪美食</a>
            </div>
        </section>
        <section class="extra">
            <a href="#">
                <img src="./images/extra_1.png" alt=""/>
            </a>
            <a href="#">
                <img src="./images/extra_2.png" alt=""/>
            </a>
        </section>
    </main>
    <footer>
        <nav>
            <a href="#">电话预定</a>
            <a href="#">下载客户端</a>
            <a href="#">我的</a>
        </nav>
        <p class="link">
            <a href="#">网站地图</a>
            <a href="#">English</a>
            <a href="#">电脑版</a>
        </p>
        <p class="copyright">&copy;猪猪旅行</p>
    </footer>
</div>

</body>
</html>

相关文章

网友评论

    本文标题:flex之伸缩网页

    本文链接:https://www.haomeiwen.com/subject/qkubcctx.html