【发布时间】:2014-04-05 07:43:05
【问题描述】:
我有这个 html:
<div class="template">
<div class="template-header"></div>
<div class="template-navigation"></div>
<div class="template-content">
<div class="template-content-left"></div>
<div class="template-content-middle"></div>
<div class="template-content-right"></div>
</div>
<div class="template-footer"></div>
</div>
使用这个 css:
*
{
margin: 0;
padding: 0;
}
body, html
{
height: 100%;
min-height: 100%;
}
.template
{
height: 100%;
}
.template-header
{
background: gray;
height: 100px;
}
.template-navigation
{
background: blue;
height: 50px;
}
.template-content
{
height: calc(100% - 200px);
}
.template-content-left
{
float: left;
background: black;
height: 100%;
width: 200px;
}
.template-content-middle
{
background: magenta;
height: 100%;
float: left;
width: calc(100% - 400px);
}
.template-content-right
{
float: right;
background: black;
height: 100%;
width: 200px;
}
.template-footer
{
background: blue;
height: 50px;
}
我无法让template-content 填充剩余的高度,也无法让template-content-middle 填充剩余的宽度。
以下必须是固定高度: 模板头 模板导航 模板页脚
以下必须是固定宽度: 模板内容左 模板内容权利
寻找跨浏览器的解决方案。如果可能,希望避免使用 javascript/jquery。
任何帮助将不胜感激。
【问题讨论】:
-
height: 100%如果父级的高度为 100%(这适用于相对和静态),哪个父级也有 100%,依此类推,直到每个父级必须有 100% 的 body/html 标签.所以在你的情况下这不是一个好主意,所以你应该使用 javascript 并计算高度以便应用它。 -
我确实有 html,正文设置为 100% 高度。