我有一个表格,单元格的内容完全填充它们。我给内容设置了固定的宽度和height
为100%
,这样更大的元素仍然能够增加单元格的大小。通过简单的height
属性,单元格还具有最小高度,以便内容的100%高度产生影响。在Chrome和Edge中,一切正常,但在Firefox中,单元格不会增长:
Chrome:
Firefox:
如果你想自己尝试:
table {
border-spacing: 8px;
font-size: 14px;
}
td {
height: 50px;
}
td div {
height: 100%;
width: 200px;
background-color: green;
}
<table>
<tr>
<td>
<div>
This div is normal sized.
</div>
</td>
<td>
<div>
This div is normal sized.
</div>
</td>
</tr>
<tr>
<td>
<div>
This div is also normal sized but should size accordingly.
</div>
</td>
<td>
<div>
This div is very very big so it gets higher and should affect other divs in the same row. But not in Firefox apparently.
</div>
</td>
</tr>
</table>
width
和height
属性被用作min-width
/min-height
,并根据其内容增长。是否有一个快速的解决方法,或者我应该在flexbox布局中重建表格?更新:
顺便说一下,当我在行/
tr
上设置了固定的height
,并在td上设置了height: 100%;
时,在Firefox中它可以工作。但在Chrome中它就会出问题...