<table>
<tr>
<td style="height:1px;">
<div style="border:1px solid red; height:100%;">
I want cell to be the full height
</div>
</td>
<td>
This cell
<br/>is taller
<br/>than the
<br/>first one
</td>
</tr>
</table>
通过设置height of the td to 1px, 孩子div可以设置height:100%。在 Chrome 和 IE 中100%然后被解释为“单元格的高度”,而在 Firefox 中,它似乎成为单元格所需的最大高度div的内容。
在 Firefox 中运行上面的示例将直观地说明这一点......
因此,我正在寻找一种也适用于 Firefox 的解决方案。
尝试添加display: table到你的嵌套<div>,并改变height: 1px to height: 100%在父母身上<td>
<table>
<tr>
<td class="fix_height">
<div style="border:1px solid red; height:100%; display:inline-table">
I want cell to be the full height
</div>
</td>
<td>
This cell
<br/>is taller
<br/>than the
<br/>first one
</td>
</tr>
</table>