因此,在我的代码中,我有一个粘性页脚。粘性页脚的#wrap容器的min-height为100%。但是在min-height中,你不能在包装div中的对象上使用height:100%。
所以我添加了height:100%,但当窗口高度太小时,它会使页脚滚动到换行div中的内容上,从而扰乱布局。
有人有解决这个问题的办法吗?
<div id="wrap">
<div id="main">
<div id="content">
</div>
</div>
<div class="clearfooter"></div>
</div>
<div id="footer">
</div>CSS:
*{
padding: 0px;
margin: 0px;
}
html, body {
height: 100%;
}
body{
color: #FFF;
background-image:url('../images/black_denim.png');
}
#wrap {
min-height: 100%;
margin-bottom: -200px;
position: relative;
}
#topBanner{
width: 200px;
margin: 0px auto;
}
.clearfooter {
height: 200px;
clear: both;
}
/* footer */
#footer {
position: relative;
height: 200px;
width: 100%;
min-width: 960px;
}发布于 2012-12-23 05:44:19
如果你所需要的只是一个粘性的页脚,不会遮盖任何正文的内容,那么只需要给页脚一个固定的位置,并让正文的底部填充等于页脚的高度。
body{
padding-bottom:200px;
}
#footer {
position: fixed;
bottom:0;
height: 200px;
width: 100%;
}编辑:
如果你担心的是,在非常小的屏幕上,固定的页脚覆盖了大部分屏幕,那么除了使用css媒体查询或javascript动态隐藏页脚之外,没有其他解决办法。
许多移动浏览器不支持固定位置,正是因为它们覆盖了大部分屏幕的问题。
https://stackoverflow.com/questions/14006720
复制相似问题