zoukankan      html  css  js  c++  java
  • 简单而兼容性好的Web自适应高度布局,纯CSS

    纯CSS实现的自适应高度布局,中间内容不符自动滚动条。兼容IE9以上、chrome、FF。关键属性是box-sizing: border-box。

    不废话,直接上代码:

    <!doctype html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <style>
        *{padding:0;margin:0}
        .head{
            height:90px;
            background: #090;
            position: absolute;
            width: 100%;
        }
        .content{
            height:100%;
            background: #808;
            position: absolute;
            width: 100%;
            padding:90px 0 30px 0;
            box-sizing: border-box;
            z-index: -1;
        }
        .foot{
            height:30px;
            background: #890;
            position: fixed;
            bottom:0;
            width: 100%;
        }
        .cnt{
            height:100%;
            overflow: auto;
        }
    </style>
    <body>
    <div class="head">Head</div>
    <div class="content">
        <div class="cnt">
            内容<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 here</div><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/><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/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
            内容
        </div>
    </div>
    <div class="foot">Foot</div>
    </body>
    </html>
  • 相关阅读:
    PHP实现多进程并行操作(可做守护进程)
    检测php文件是否有bom头
    安全过滤函数
    模式修正符
    php中const与define的使用区别
    常要用正则表达式
    htaccess 伪静态的规则
    把返回的数据集转换成数组树
    ExtJS实战(3)spring
    ExtJS实战(4)struts
  • 原文地址:https://www.cnblogs.com/hz-blog/p/CSS-Auto-Fix-Height-Layout.html
Copyright © 2011-2022 走看看