【发布时间】:2011-11-19 07:14:42
【问题描述】:
我正在尝试实现一个 sticky footer,它正在工作,除了主包装 div 的 100% 高度延伸得太高(#body-wrap)并且它在内容和页脚之间造成了巨大的差距。因此,我必须将页面向下滚动到巨大的空白处才能查看它。
我的 HTML 是这样的:
<div id="body-wrap">
<div id="content">
[about 100px of content here]
</div><!-- end #content -->
<div class="push"></div>
</div><!-- end #body-wrap -->
<div id="footer-wrap">
<div id="footer-content">
[about 300px of content here]
</div> <!-- end #footer-content -->
</div> <!-- end #footer-wrap -->
还有我的 CSS:
html, body {
height: 100%;
}
#body-wrap {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -300px; /* the bottom margin is the negative value of the footer's height */
}
.footer-main-wrap, .push {
height: 300px; /* .push must be the same height as .footer */
}
有人知道为什么 100% 的高度会比内容延伸得更远吗?
【问题讨论】:
-
您是否也忘记在原始来源中添加引号
"?当我准备我的答案时,右引号的缺失导致了不同的布局(FF 3.6.22)。
标签: css height footer sticky-footer