【发布时间】:2015-04-13 17:35:01
【问题描述】:
我正在尝试使用 display table-cell 属性创建一个两列 100% 高度的布局。它在 Chrome 上运行良好,但我在 Firefox 和 IE 上都没有成功。
这里是小提琴:http://jsfiddle.net/ehfa0kk8/5/
看看它是如何在 Chrome 上运行的。知道如何进行这项工作吗?
<div id="table">
<div id="row">
<div id="cell_1">
<div id="overflown_div">
long content goes here...
</div>
</div>
<div id="cell_2">
Blah blah blah
</div>
</div>
</div>
还有 CSS
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#table {
width: 100%;
display: table;
height: 100%;
}
#row {
display: table-row;
}
#cell_1, #cell_2 {
display: table-cell;
height: 100%;
}
#cell_1 {
width: 390px;
background: aliceblue;
}
#cell_2 {
background: yellow;
}
#overflown_div {
height: 100%;
overflow: scroll;
padding: 10px;
}
更新:首先,左列应该有足够的内容,这样它就会溢出。在 Chrome 上,它会显示一个滚动条,因此您可以只滚动该列(单元格)的内容。在 Firefox 上不会发生。
示例:
【问题讨论】:
-
什么不起作用?我在 Firefox 中看到 2 个全高列。
-
首先,我不知道你的屏幕有多大,但是左栏应该有很长的内容,所以它会溢出。在 Chrome 上,它会显示一个滚动条,因此您可以只滚动该列(单元格)的内容。在 Firefox 上不会发生这种情况
-
在 Firefox 上看起来不错,你能发一个截图来解释这个问题吗?
-
@sdcr,我刚刚做到了。请注意 Chrome 上溢出 div 上的滚动条,但在 Firefox 上 100% 高度不起作用。