我正在尝试修复页脚的一个错误,正如您所看到的,页脚没有像应该一样停留在浏览器底部,如果页面内容不足,则停留在页面中间,它只是跟随其余div的高度。网站示例:http://produccion.pugle.net/sarahbcn2/membership-cancelled/
因此,我尝试使用一些CSS命令在主div包装器上进行修复,例如overflow:auto;或height:auto;并为页脚使用相同的命令,但没有成功。有任何想法解决这个问题吗?
谢谢
<div class="page-wrap">
<h1>Sticky Footer</h1>
<h2>with Fixed Footer Height</h2>
<button id="add">Add Content</button>
</div>
<footer class="site-footer">
I'm the Sticky Footer.
</footer>
* {
margin: 0;
}
html, body {
height: 100%;
}
.page-wrap {
min-height: 100%;
/* equal to footer height */
margin-bottom: -142px;
}
.page-wrap:after {
content: "";
display: block;
}
.site-footer, .page-wrap:after {
/* .push must be the same height as footer */
height: 142px;
}
.site-footer {
background: orange;
}
footer {
background: none repeat scroll 0 center #fff;
bottom: 0;
display: block;
margin: 0 auto;
padding: 80px 0 0;
position: fixed;/*fixed position*/
width: 100%;
}