【发布时间】:2013-05-09 02:56:45
【问题描述】:
我搜索了许多论坛和问题,但找不到任何有关流体垂直(不是水平布局)的信息。
我的标记如下:
<div class="wrapper">
<div class="header"></div>
<div id="content"></div>
<div class="footer"></div>
</div>
我的 CSS:
html,body {margin: 0; padding: 0; height: 100%;}
.wrapper {width: 900px; margin: 0 auto; height:auto !important; height:100%; min-height:100%; position: relative;}
#content {padding-bottom: 60px; /* For the footer padding */ }
.footer { position: absolute; bottom: 15px; height: 45px;}
在这种情况下,我的布局具有标题和内容的固定高度。页脚粘在底部。
这一切都很好,但我想制作流畅的垂直布局,以便页脚始终粘在底部(就像现在一样),但页眉和内容具有流畅的高度:相应地为 30% 和 70%。
我怎样才能做到这一点?
【问题讨论】:
-
我不太确定您想要实现什么。页脚具有固定高度,并且页眉/内容都应该拉伸以填充其余部分? (保持 30:70 的比例)?
-
是的,我想完全实现你写的!
-
内容扩展过多时会变得很棘手。例如,假设视口的高度是 1045px。然后页脚占用 45 像素,页眉 300 像素和内容 700 像素。但是假设现在标题包含一个 600px 高的图片,而内容 - 200px 高的图片?那么尺寸应该如何呢?您是放弃 30:70 的比例以将所有内容都保留在屏幕上,还是将标题拉伸到 600 像素,将内容拉伸到 1400 像素?或者也许您将它们保持在 300px/700px 并在标题中添加滚动条?或者只是剪掉标题图片?
标签: css