【发布时间】:2013-07-20 09:22:00
【问题描述】:
只是另一个“粘滞页脚”问题。
HTML:
<body id="mainbody">
<div class="wrapper">
<div id="header">
</div>
<div id="navbar">
</div>
<div id="sidebar">
</div>
<div id="content">
</div>
<div class="push"></div>
</div>
<div class="footer">
<p>© LOREM IPSUM DOLOR ...</p>
</div>
CSS:
.footer {
text-align:center;
color:#ffffff;
position: relative;
z-index: 10;
margin-bottom: 0px;
line-height:30px;
width:1100px;
left:100px;
border:1px solid #777777;
background:#261f1f;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
-moz-box-shadow: 5px 5px 5px #000000;
-webkit-box-shadow: 5px 5px 5px #000000;
box-shadow: 5px 5px 5px #000000;
}
/*Footer to buttom*/
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -32px;
}
.footer, .push {
height: 30x;
clear:both;
}
我在这个网站和其他网站上阅读了很多帖子。当我使用位置:固定在页脚中时,页脚会粘在浏览器“窗口”或“屏幕”的底部。无论我重新缩放还是移动,它都保留在那里。这涵盖了主要内容,但至少始终处于底部
当我使用位置时:相对;如果滚动条在顶部,它会停留在底部。但是当我向下滚动条时,页脚会移动到主要内容上,甚至不会移动到底部。
我犯了什么错误?我希望页脚保持在底部:页面的所有内容下方。
这是使用 fixed: 时会发生的情况
【问题讨论】:
-
所以你不能使用
relative..为什么不使用fixed? -
如果你不想要
position:fixed你应该有一些JS或jQuery代码 -
@Cherniv 和 ABFORCE 粘性是什么意思?我的意思是我希望页脚转到页面的底部,而不是窗口。
-
@HashemQolami,是的!但问题是我在使用该线程后就在这里。它不是重复的。最好的建议在这里不起作用。它不是重复的!!!