Over here, this question has been answered for IE and Chrome, but the proposed solution does not seem to work in Firefox 16, 45, and probably all versions in between.
Basically, the proposed solution is as follows:
table,th,td {
border: 1px solid black;
}
<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 higher
<br/>than the
<br/>first one
</td>
</tr>
</table>
By setting the height
of the td
to 1px
, the child div
can set height:100%
. In Chrome and IE the 100%
is then interpreted as "the height of the cell", while in Firefox it seems to become the max height needed for the div
s content.
Running the example above in Firefox will illustrate this intuitively...
So, I'm looking for a solution that -also- works in Firefox.
Try adding display: table
to your nested <div>
, and change height: 1px
to height: 100%
on the parent <td>
Example that works in Firefox, IE and Chrome
table,
th,
td {
border: 1px solid black;
}
.fix_height {
height: 1px;
}
@-moz-document url-prefix() {
.fix_height {
height: 100%;
}
}
<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 higher
<br/>than the
<br/>first one
</td>
</tr>
</table>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With