I'm writing this question in an attempt to consolidate the multiple similar questions on this site and finally get a proper yes or no answer to the question. Several existing answers have been incorrectly marked as correct when, in fact, they do not work properly.
Already read, related questions.
- height: 100% for <div> inside <div> with display: table-cell
- Making inner div heights 100% with css in a table-cell
- Full height div inside td
- DIV stretch to height 100% in a table cell
- Getting div to occupy full cell height
- How to make <div> fill <td> height
Given the following markup:
<div class="equal-height">
<div class="col-50">
<div class="cell-fill">
...
</div>
</div>
<div class="col-50">
<div class="cell-fill">
...
</div>
</div>
</div>
Is it possible to get the divs with the class cell-fill
to span 100% of their container height using CSS alone across the following browsers?
- Chrome - Latest
- Opera - Latest
- Safari - Latest
- Firefox - Latest
- IE9+
The closest I can get is this example:
The version given works in latest Chrome, Opera, Safari, and Firefox. It also works in IE11 but fails to fill full height on both IE9 and IE10.
In those browsers the height of the cell-fill
will grow if the outer equal-height
element has its height set to a pixel value greater than the smallest column so perhaps a solution can be found based on that behaviour.
Current CSS
/*
* 1. Stop columns and rows collapsing.
* 2. Set height so Chrome and IE11 work.
*/
.equal-height {
display: table;
table-layout: fixed; /*1*/
height: 1px; /*2*/
width: 100%;
}
/*
* 1. Inherit and pass on height.
* 2. Fill full height.
*/
.col-50{
width:50%;
height:100%; /*1*/
display:table-cell; /*2*/
}
/*
* 1. Force Layout.
* 2. Fill full height.
* 3. So we can see it.
*/
.cell-fill{
display:table; /*1*/
height:100%; /*2*/
background-color: #ff69b4 /*3*/
}