我有一个页面,使用各种表格式显示值,以尝试使页面的正文自动填充页眉和页脚之间的空白部分。
在正文中,我浮动了两个div,左侧和右侧。右侧浮动的div设置为"height: 100%",因为我想要使用一个插入式盒阴影来可视化地分割两个div的内容。只要左侧div中的内容不足以导致页面需要滚动条,所有这些都能正常工作。但是,一旦发生这种情况,右侧浮动的div似乎不再尊重其高度值,并且恢复其高度由其内容确定的状态。
jsFiddle工作演示:http://jsfiddle.net/ec3upxk7/4/ 停止工作的链接:http://jsfiddle.net/yw3vLess/2/ 这是工作示例的代码:
HTML:
在正文中,我浮动了两个div,左侧和右侧。右侧浮动的div设置为"height: 100%",因为我想要使用一个插入式盒阴影来可视化地分割两个div的内容。只要左侧div中的内容不足以导致页面需要滚动条,所有这些都能正常工作。但是,一旦发生这种情况,右侧浮动的div似乎不再尊重其高度值,并且恢复其高度由其内容确定的状态。
jsFiddle工作演示:http://jsfiddle.net/ec3upxk7/4/ 停止工作的链接:http://jsfiddle.net/yw3vLess/2/ 这是工作示例的代码:
HTML:
<div class="container">
<header class="header">
<p>This is the header</p>
</header>
<section class="content">
<div class="content-body">
<div class="left-panel">
<p>This is the content.</p>
</div>
<div class="right-panel">
<p>This is not the content.</p>
</div>
</div>
</section>
<footer class="footer">
<p>This is the footer.</p>
</footer>
</div>
CSS:
/* Reset */
html, body { height: 100%; margin: 0; padding: 0; }
/* Essentials */
.container { display: table; }
.content { display: table-row; height: 100%; }
.content-body { display: table-cell; }
/* Aestetics */
.container { width: 100%; height: 100%; }
.header, .footer { padding: 10px 20px; background: #f7f7f7; }
.content-body { background: #e7e7e7; }
.left-panel {
width: 50%;
float: left;
}
.right-panel {
width: 49.9%;
height: 100%;
float: right;
box-shadow:
inset 10px 0px 5px -7px rgba(0,0,0,0.5);
}