【发布时间】:2011-11-23 12:54:43
【问题描述】:
我有三个div 元素:一个作为页眉,一个作为页脚,一个中心内容div。
中心的div 需要随内容自动扩展,但我想要一个min-height,这样底部的div 总是至少到达窗口的底部,但在较长的页面上不会固定在那里.
例如:
<div id="a" style="height: 200px;">
<p>This div should always remain at the top of the page content and should scroll with it.</p>
</div>
<div id="b">
<p>This is the div in question. On longer pages, this div needs to behave normally (i.e. expand to fit the content and scroll with the entire page). On shorter pages, this div needs to expand beyond its content to a height such that div c will reach the bottom of the viewport, regardless of monitor resolution or window size.
</div>
<div id="c" style="height: 100px;">
<p>This div needs to remain at the bottom of the page's content, and scroll with it on longer pages, but on shorter pages, needs to reach the bottom of the browser window, regardless of monitor resolution or window size.</p>
</div>
【问题讨论】: