所有可用的高度我有这样的HTML结构:填补了父母箱
#### body #######################
# #
# ###### .box ####### #
# # .box-header # #
# ################### #
# # # #
# # # #
# # .box-body # #
# # # #
# # # #
# ################### #
# # .box-footer # #
# ################### #
# #
#################################
你可以看到代码here。
仅供参考,HTML:
<div class="box">
<div class="box-header">
<h1>.box-header</h1>
</div>
<div class="box-body">
<h2>.box-body</h2>
<p>This should fill up the available space in order to move the box-footer to the bottom.
<br/><br/>
If this it has been done right the red background should not be displayed.
</p>
</div>
<div class="box-footer">
<h3>.box-footer</h3>
</div>
</div>
和CSS:
body{
height: 400px;
}
.box{
padding: 0px;
margin: 0px;
height: inherit;
background-color: red;
}
.box-header{
background-color: green;
padding: 0px;
margin: 0px;
}
.box-header h1{
padding: 10px;
margin: 0px;
}
.box-body{
background-color: blue;
}
.box-body p, .box-body h2{
padding: 10px;
margin: 0px;
color: white;
}
.box-footer{
padding: 10px;
margin: 0px;
background-color: black;
}
.box-footer h3{
padding: 10px;
margin: 0px;
color: white;
}
有没有办法迫使.box-body
填满.box
的所有可用的高度?
请注意,这是我的html的清洁版本。真实的例子有顶部,底部和左边的固定栏。我所试图做的是添加第二个左侧边栏...
是的,就是这样! :D我试图将高度设置为100%,但没有显示表格和表格行,body元素获得父框的总高度而没有折扣其他子元素(页眉和页脚)。非常感谢! – jbatista
很高兴帮助!请记住接受答案。 :) –