【发布时间】:2015-07-27 15:22:05
【问题描述】:
我使用了 display:table 属性,但表格单元格的高度仍然不相等。有没有办法在不使用 JavaScript 或 jQuery 的情况下使它们相等?必须牢记 Internet Explorer 兼容性。
<div class="envelope">
<div class="fill col">
ABC
<br><br><br>
</div>
<div class="fill ">DEF</div>
<div class="fill col">
XYZ
<br><br><br>
<br><br><br>
</div>
</div>
这是CSS
.envelope{
border:1px solid #000;
border-radius:5px;
display:table;
width:300px;
}
.fill{
background:#dddddd;
border-right:1px solid #000;
float:left;
width:30%;
padding:1%;
display:table-cell;
}
.col{
background:#ff44ff;
}
【问题讨论】:
-
你为什么使用 float 属性?如果你浮动它,那么你将不会有相同的高度,如果你推迟浮动,它会起作用
-
你应该支持什么版本的IE?
-
@francesco-es :在小提琴中它可以工作,让我看看它是否在生产环境中工作。 :)
-
顺便说一句,在那之后我告诉过你,任何人都用我的提示回答了