首页 > Web开发 > 详细

简单而兼容性好的Web自适应高度布局,纯CSS

时间:2016-08-10 15:59:42      阅读:141      评论:0      收藏:0      [点我收藏+]

纯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>

 

简单而兼容性好的Web自适应高度布局,纯CSS

原文:http://www.cnblogs.com/hz-blog/p/CSS-Auto-Fix-Height-Layout.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!