zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    ORM是什么?及ORM框架是什么?
    Spring与其两大核心
    装箱和拆箱
    ==和equals的比较
    Vue中ESlint配置文件eslintrc.js文件详解
    RESTful API规范
    CORS跨域djangosetting.py 配置
    LDAP
    模拟浏览器发送请求报文
    学HTTP协议所要知道的基础知识(微总结)
  • 原文地址:https://www.cnblogs.com/liuhp/p/9704154.html
Copyright © 2011-2022 走看看