我读过一篇非常相似的帖子并尝试了所有解决方案,但没有任何乐趣。这就是我所拥有的。我的网站具有全宽 (100%) 页眉和页脚空间以及较小宽度的容器。我使用了 Ryan Fait 粘性页脚,但容器(白色背景)不会向下延伸到页脚,除非我只是放入一堆换行符,这违背了粘性页脚的目的。
样式:
html, body {
height: 100%;}
body {
margin:0;
padding:0;
}
html {
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -30px;}
.container {
width:1050px;
margin: 0 auto 0 auto;
min-height: 100%;
height: auto !important;
height: 100%;
padding:0 25px 0 25px;
background-color:#FFF;
}
.footer, .push {
height: 30px;}
.footer {
background-color:#000;
width:100%;
height: 30px;}
和 html:
<div class="wrapper">
<div class="container">
/* content */
</div>
<!--end container-->
<div class="push"></div>
</div>
<!--end wrapper-->
<div class="footer">
/* footer */
</div>
<!--end footer-->
最佳答案
您可以去掉 .wrapper
并将 .push
移动到您的 .container
参见 fiddle :http://jsfiddle.net/32WxJ/3/
关于css - 使用粘性页脚,无法将主要内容的背景拉伸(stretch)到页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15791145/