【发布时间】:2016-08-20 17:18:45
【问题描述】:
要求是设置列的等高和等宽。我为此使用了css属性显示表格单元格,它在相等高度方面工作正常,但在相等宽度方面效果不佳。我知道从技术上讲它工作正常,但我想让它的宽度相等。所以无论一张表是四列还是一列,它都应该有一个宽度。
我也寻找过 flex,但 IE9 不支持它,并且与移动浏览器存在一些兼容性问题。我已经思考并尝试了很多方法,但没有得到解决方案。如果您想尝试一下,这里是fiddle。
HTML
.table {
display: table;
width: 100%;
height: 100%
}
.cell {
display: table-cell;
padding: 0 10px;
width: 23.8%;
height: 100%
}
.white-box {
border: solid 1px #ccc;
background: #eee;
height: 100%
}
<div class="table">
<div class="cell">
<div class="white-box">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div>
</div>
<div class="cell">
<div class="white-box">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>
</div>
<div class="cell">
<div class="white-box">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>
</div>
<div class="cell">
<div class="white-box">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>
</div>
</div>
<br>
<div class="table">
<div class="cell">
<div class="white-box">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div>
</div>
<div class="cell">
<div class="white-box">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>
</div>
</div>
【问题讨论】:
-
你知道你一共有多少个div吗?
-
我不认为这是一个重复的问题。
-
你的小提琴到底出了什么问题?
-
我的问题是无论列数如何,列宽都应该保持不变
-
@SalmanA:您可以注意到下一张表中列的宽度。它与第一个表列不同