HTML:
<div class="main" style="float:left">
lorem ipsum <br />
lorem ipsum <br />
lorem ipsum <br />
</div>
<div style="float:right">
<div class="block">block</div>
<div class="block">block</div>
<div class="block">block</div>
</div>
jQuery:
$('.block').height($(".main").height() / (3));
… each block height = height of main / 3
It is inaccurate because height doesn’t consider the margin/padding of the .block. How do I subtract the padding/margin either automatically or manually?
You need to use
outerHeightEDIT I misread the docs originally, and thought
marginwas included by default. I was wrong! Be sure to passtrueto theouterHeightfunction to include margin. Thanks @Alex Sexton!