Reputation: 63299
I have 3 divs
<div id="div1" style="float:left;">
</div>
<div id="div2" style="float:left;">
</div>
<div id="div3" style="float:left;">
</div>
In most of time div3 is the highest, I want div1 and div2 to have the same height as div3, is it possible to do?
Upvotes: 0
Views: 126
Reputation: 490163
You can use faux background or the holy grail technique.
Alternatively, you could use a dash of JavaScript...
var divIds = ['div1', 'div2', 'div3'],
divs = [],
divsLength = divIds.length,
maxHeight = 0;
for (var i = 0; i < divsLength; i++) {
var div = document.getElementById(divIds[i]);
maxHeight = Math.max(maxHeight, div.offsetHeight);
divs.push(div);
}
for (var i = 0; i < divsLength; i++) {
divs[i].style.height = maxHeight + 'px';
}
Upvotes: 4