【发布时间】:2012-06-14 09:36:40
【问题描述】:
我有这个 HTML 结构:
<div id="body">
<div id="head">
<p>Dynamic height without scrollbar</p>
</div>
<div id="content">
<p>Dynamic height with scrollbar</p>
</div>
<div id="foot">
<p>Fixed height without scrollbar</p>
</div>
</div>
我想让这三个部分在主要部分 (#body) 内没有溢出。所以中间需要一个滚动条。
我试过这个 CSS:
#content{
border: red solid 1px;
overflow-y: auto;
}
还有这个:
#content{
border: red solid 1px;
overflow-y: auto;
height: 100%;
}
但它们都不起作用。
我在JSFiddle做了一个例子。
我可以只使用 CSS 和 HTML 吗?我宁愿避免使用 Javascript。
【问题讨论】: