【发布时间】:2014-09-14 06:56:15
【问题描述】:
我在使用 display:table,table-row,table-cell 时遇到了一些奇怪的 CSS 行为
当一个表格单元格包含一个空的 div 时,它会下推它旁边的单元格的内容。
<html>
<body>
<div style="height:200px">
<div style="display:table">
<div style="display:table-row">
<div style="display:table-cell">
<div style="height:100px;width:200px;overflow-y:scroll"></div>
</div>
<div style="display:table-cell">
<div style="height:100px;width:100px;overflow-y:scroll">Why am I getting pushed down?!?</div>
</div>
</div>
</div>
</div>
<div style="height:200px">
<div style="display:table">
<div style="display:table-row">
<div style="display:table-cell">
<div style="height:100px;width:200px;overflow-y:scroll">A</div>
</div>
<div style="display:table-cell">
<div style="height:100px;width:100px;overflow-y:scroll">Suddenly I'm not getting pushed down?!?</div>
</div>
</div>
</div>
</div>
</body>
</html>
如果我在 DIV 中放入一些内容,行为就会停止。这是一个错误吗?影响 Firefox 和 Chrome。如果不是错误,我该如何解决?
【问题讨论】: