【发布时间】:2011-08-13 22:13:30
【问题描述】:
<div id="top">
*height: auto;
min-height: 100%;*
<div id="content">
*min-height: 500px;*
</div>
<div id="middle">
*css ???*
</div>
</div>
<div id="footer">
</div>
当屏幕尺寸正常时,此代码运行良好。但在全屏模式下,页脚进入页面底部(需要的行为),但“中间”div 必须增加其高度才能获得页脚。我的意思是,这 3 个元素(内容、中间和页脚)必须是连续的。
我应该使用哪些 css 规则来执行此行为?
提前致谢!
更新。
我使用了几个 css 规则和作品,但在 IE8 中没有(在 IE9、Chrome、FF3 和 FF4 中有效)。相关的 CSS 是:
Top{ height: auto; }
Content{ min-height: 100%; }
Middle{ overflow: auto; padding-bottom: 130px; }
Footer{ clear: both; height: 130px; margin-top: -130px; position: relative; }
【问题讨论】:
-
您希望页脚始终停留在屏幕底部,还是在内容向下推动时滚动?
-
@Thomas 总是在底部,但不固定。
-
啊,好的。然后查看我关于媒体查询的答案。您可以根据视口高度设置宽度和高度以及任何其他 css 属性。