该问题的解决方法是在CSS样式表中添加以下代码:
html,body{ height:100%; }
.container{ min-height:100%; height:auto !important; margin-bottom:-50px; }
.container:after{ content:" "; display:block; height:50px; }
其中,html和body的高度都是设为100%。container的最小高度为100%,高度设为自适应,因为它应该由内容自动撑开。为了避免在内容不够多的时候网站主体部分出现空白,使用负的margin-bottom。最后,在container的后面添加一个空的块级元素占位,高度等于负的margin-bottom,以确保页面底部的内容不会被覆盖。