zoukankan      html  css  js  c++  java
  • 弹性盒布局、头尾固定中间部分自适应布局

    一、弹性盒布局
    HTML页面:

    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>我的弹性盒布局</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
    <link rel="stylesheet" href="css/style.css"/>
    </head>
    <body>
    <div class="container">
    <header>头部</header>
    <section>

    </section>
    <footer>
    <nav>
    <a href="">首页</a>
    <a href="">收藏</a>
    <a href="">历史</a>
    <a href="">设置</a>
    </nav>
    </footer>
    </div>
    </body>
    </html>

    less文件
    @import "m_reset.css";
    //重置的css文件地址: http://files.cnblogs.com/files/heyiming/m_reset.css
    //封装的内容
    .wh(@w,@h){@w; height:@h;}
    .b(@b){background: @b; }
    .fl{float: left;}
    .fr{float: right;}
    .lh(@lh){line-height: @lh;}
    .pl(@pl){padding-left: @pl;}
    .pr(@pr){padding-right: @pr;}
    .pt(@pt){padding-top: @pt;}
    .pb(@pb){padding-bottom: @pb;}
    .ml(@ml){margin-left: @ml;}
    .mr(@mr){margin-right: @mr;}
    .mt(@mt){margin-top: @mt;}
    .mb(@mb){margin-bottom: @mb;}
    .m{margin:0 auto}
    .bb(@bb){border-bottom: @bb}
    .bt(@bt){border-top: @bt}

    .container,html,body{.wh(100%,100%)}
    .container{
    .wh(100%,100%);
    display:-webkit-box;//定义一个弹性盒
    -webkit-box-orient:vertical;//将弹性盒设置为垂直
    }
    header{
    .wh(100%,50px);
    .b(red);
    text-align: center;
    .lh(50px);
    color:#fff;
    }
    //主题部分
    section{
    .b(#f1f0f6);
    -webkit-box-flex:1;
    overflow:scroll;
    text-align: center;
    //-webkit-box-pack:center;
    //-webkit-box-align:center;
    }
    footer{
    .wh(100%,50px);
    .b(#000);
    nav{
    display: -webkit-box;
    height: 50px;
    a{
    display: block;
    -webkit-box-flex: 1;
    text-align: center;
    .lh(50px);
    color: white;
    }
    }
    }



    二、头、尾固定中间部分自适应布局(拷贝以下代码即可实现)
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="utf-8">
    <title>头尾固定中间高度自适应布局</title>
    <style>
    html, body {
    height:100%;
    margin:0;
    padding:0
    }
    header {
    100%;
    height:4rem;
    line-height:4rem;
    background:red;
    position:absolute;
    z-index:5;
    top:0;
    text-align:center;
    }
    #main {
    background:pink;
    100%;
    overflow:auto;
    top:4rem;
    position:absolute;
    z-index:10;
    bottom:4rem;
    }
    footer {
    height:4rem;
    line-height:4rem;
    background:yellow;
    100%;
    position:absolute;
    z-index:200;
    bottom:0;
    text-align:center;
    }
    </style>
    </head>
    <body>
    <header>固定头部4rem</header>
    <div id="main">
    <div class="mycontent">
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    中间自适应部分<br>
    </div>
    </div>
    <footer>固定尾部4rem</footer>
    </body>
    </html>
    
    
  • 相关阅读:
    php+Nginx 安装手册
    PostgreSQL 生成uuid
    登陆服务器错误: Disconnected:No supported authentication methods available
    安装Tengine
    netty解决方法 io.netty.util.IllegalReferenceCountException: refCnt: 0, increment: 1
    IntelliJ Idea 2016,2017,2018 注册码 免费激活方法
    jdbc连接"Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driv"
    mysql错误:you are using update mode and you tried to update a table without a where that uses a key column to disable safe mode
    spring介绍;安装;使用
    设置maven仓库阿里镜像
  • 原文地址:https://www.cnblogs.com/heyiming/p/5686212.html
Copyright © 2011-2022 走看看