您的位置:首页 > Web前端 > CSS

Footer固定在页面底部(CSS)

2016-04-27 21:34 471 查看
<styletype="text/css">
  #wapper{
position:relative;/*重要!保证footer是相对于wapper位置绝对*/
height:auto;
min-height:100%;
}
  #main-content{
background:grey;
padding-bottom:60px;/*重要!给footer预留的空间*/
}
  #footer{
    background:green;
    width:100%;
    position:absolute;
    bottom:0;/*关键*/
    height:60px;/*此方法的缺点:页脚的高度需要手动调*/
  }
</style>
<bodystyle="margin:0">
<divid="wapper">
<!--主要内容-->
<divid="main-content">
这里是内容
</div>
<!--页脚-->
<divid="footer">
这里是页脚
</div>
</div>
</body>

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: