Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make div 100% height of TD (IE issue)

Tags:

html

css

Given the following html sample, how can I make the absolute positioned div height 100% of the table cell. This is only an issue for IE.

The catch is that div must not affect the cell contents, hence the position absolute, and the row style must define the height.

<html>
<table>
<tr style="height:100px;">
<td style="position:relative;width:200px;background-color:green;border:solid 2px green;">
    <div style="position:absolute;background-color:red;width:100%;height:100%;top:0px;left:0px;"></div>
    xyz
</td>
</tr>
</table>
</html>
like image 865
MarzSocks Avatar asked Dec 11 '25 11:12

MarzSocks


1 Answers

I've actually solved this by applying a "height:inherit" on div and the parent the td.

<html>
<table>
<tr style="height:100px;">
<td style="position:relative;width:200px;height:inherit;background-color:green;border:solid 2px green;">
    <div style="position:absolute;background-color:red;width:100%;height:inherit;top:0px;left:0px;"></div>
    xyz
</td>
</tr>
</table>
</html>
like image 140
MarzSocks Avatar answered Dec 14 '25 03:12

MarzSocks