【发布时间】:2011-11-15 12:57:59
【问题描述】:
如何将 html 元素设置为在具有固定高度标题的页面上具有 100% 的高度?布局当然不是固定高度。
我已经将html 和body 设置为正确模拟min-height: 100%。
我尝试了以下想法,但无济于事:
1.我使用了以下 CSS,但它使用了基于百分比的高度,因为我的布局标题的高度是固定的 81px,所以效果不佳。
#divContent
{
height: 82%;
margin: 0;
padding: 0;
position: absolute;
top: 82px;
width: 950px;
}
2.我在padding和margin的各种组合中使用了以下,但它们都扩大了页面的高度(即hidden),从而使它们看起来都是同样:底部81px 被隐藏。
html, body
{
overflow: hidden;
margin-bottom: 82px;
padding-bottom: 82px;
}
#divContent
{
height: 100%;
margin: 0;
padding: 0;
position: absolute;
top: 82px;
width: 950px;
margin-bottom: 82px;
padding-bottom: 82px;
}
我希望我的divContent 消耗身体的所有高度减去81px。
我知道如何使用表格立即执行此操作,但那将是表格使用不当。我也认为它可以使用 jQuery 自动计算,但我之前没有写过这样的 jQuery。
附注我已经浏览了大约十几个问题,但找不到解决方案。如果你能证明这是一个实际上涵盖相同问题的副本,我很乐意阅读其他帖子。
【问题讨论】:
标签: jquery html css layout height