我有一个页面使用各种表格显示值,试图让我的页面主体自动填充页眉和页脚之间的空间。
我有两个 div,在 body 内左右浮动;右边的 float div 设置为“高度:100%”,因为我想要一个插入框阴影,我用它来明显地分割两个 div 的内容。只要左侧 div 中的内容长度不足以导致页面需要滚动条,所有这些都可以正常工作,一旦发生这种情况,右侧 float 的 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);
}
最佳答案
改变
float: right;
在右侧面板 到
display: inline-block;
这为阴影提供了 100% 的高度。
喜欢这个 fiddle :http://jsfiddle.net/yw3vLess/5/
关于html - float div 不考虑高度值的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26840908/