1
我需要一个包含标题和内容部分的网页。使用非固定标题的流体高度
标题的内容将是可变高度的内容也。页面应该是100%,如果内容div溢出,它应该显示一个滚动条(仅用于内容div而不是整个页面)。
我想保持从JQuery的/ JS解决方案,转而采用CSS解决这个
<div class="body"><!-- 100% height -->
<div class="header">
<h1>Header</h1>
<p>Variable content with max-height</p>
</div>
<div class="content">
<p>Variable content with scroll-y</p>
<p>Variable content with scroll-y</p>
<p>Variable content with scroll-y</p>
<p>Variable content with scroll-y</p>
<p>Variable content with scroll-y</p>
<p>Variable content with scroll-y</p>
<p>Variable content with scroll-y</p>
<p>Variable content with scroll-y</p>
<p>Variable content with scroll-y</p>
<p>Variable content with scroll-y</p>
<p>Variable content with scroll-y</p>
<p>Variable content with scroll-y</p>
<p>Variable content with scroll-y</p>
<p>Variable content with scroll-y</p>
<p>Variable content with scroll-y</p>
</div>
</div>
<style>
div.body{
height: 100%;
}
div.header{
max-height: 100px;
overflow: hidden;
}
div.footer{
overflow-y: ???
/* 100% - height of header */
}
</style>
我想有一个全屏页面,这限制了内容为固定的240像素。 – 2015-02-12 07:20:53
啊好吧,我现在理解..给我几秒钟,我会发布一个新的答案,这可能会工作。 – MrMAG 2015-02-12 07:53:14
尝试新的代码片段。如果您运行代码段,使用“整页”来查看结果! – MrMAG 2015-02-12 08:09:13