• HTML5使用伸缩布局实现网页的自适应


    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>flex弹性布局</title>
    <style>
    *{
    padding: 0;
    margin: 0;
    }
    header{
    100%;
    display: flex;
    }
    header > a{
    flex: 1;
    }
    header > a >img{
    100%;
    }

    main{
    100%;
    padding: 0 10px;
    box-sizing: border-box;
    }
    main > .item{
    100%;
    height: 100px;
    background-color: #57c3ae;
    border-radius: 10px;
    margin-top: 10px;
    display: flex;
    }
    main > .item:nth-last-of-type(2){
    background-color: #3c7267;
    }
    main > .item:nth-last-of-type(3){
    background-color: #332f38;
    }
    main > .item:nth-last-of-type(4){
    background-color: #723c4c;
    }
    main > .item >.left{
    flex: 1;
    }
    main > .item >.right{
    flex: 2;
    flex-wrap: wrap;
    display: flex;
    }
    main > .item >.right >a{
    display: block;
    50%;
    border-left: 1px solid #fff;
    border-bottom: 1px solid #fff;
    box-sizing: border-box;
    line-height: 50px;
    color: #fff;
    text-decoration: none;
    text-align: center;
    }
    main > .item >.right >a :nth-last-of-type(-n+2){
    border-bottom: none;
    }

    main >.extra{
    100%;
    display: flex;
    }
    main >.extra >a {
    flex:1;
    }
    main >.extra >a >img {
    100%;
    }

    footer{
    100%;
    font-size: 13px;
    }
    footer > nav{
    100%;
    display: flex;
    border-top: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    }
    footer > nav > a{
    flex: 1;
    line-height: 30px;
    text-align: center;
    color: #888;
    text-decoration: none;
    }
    footer > .link{
    text-align: center;
    line-height: 25px;
    }
    footer > .copyRight{
    text-align: center;
    }
    </style>
    </head>
    <body>
    <div class="contai">
    <header>
    <a href="">
    <img src="./images/test1.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/she.jpg" alt="">
    </a>
    <a href="">
    <img src="./images/telangpu.jpg" 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;2015 携程旅行</p>
    </footer>
    </div>
    </body>
    </html>
  • 相关阅读:
    Orcale三层嵌套实现分页功能
    在VM虚拟机上安装Microsoft Dynamics CRM 2016 步骤图解及安装注意事项
    CSS 选择器 关系
    C#获取当前程序运行路径的方法集合//获取当前进程的完整路径
    连接QuickBooks Online实现于IOS App数据同步功能的个人记录
    Posix定义的进程线程同步系统调用
    SQL SERVER 数据库事物日志 备份 收缩 腾出空间
    JAVABEAN递归转MAP实现
    第一次迭代——视频点播系统
    cstddef定义了NULL
  • 原文地址:https://www.cnblogs.com/liuhp/p/9704154.html
Copyright © 2020-2023  润新知