Create two div columns with the same height
<div id="content">
<div id="leftColumn">
left column stuff
</div>
<div id="rightColumn">
right column sidebar stuff
</div>
</div>
When the left column is longer than the right, the background image of the right column is turned off. How to make both columns the same height? (I tried applying a background image to the contents of the div and fixed the problem, but some pages do not use the sidebar, so I'm trying to find a different solution).
columns also cannot be fixed heights.
If you care about IE6 and IE7, the easiest answer is to install
display: table-cell;
.
http://ie7nomore.com/css2only/table-layout/ CSS2.1 ( , / )
, " ", : table CSS display , HTML table, div ( .. ) - , :)
IE6 IE7 (, , ... , IE - )
, , , div. , , , , .
kjy112 , , , IE6 7.
: http://css-tricks.com/fluid-width-equal-height-columns/
, . : http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks
:
"" , html :
<div id="content">
<div id="leftColumn" class="elements">
left column stuff
</div>
<div id="rightColumn" class="elements">
right column sidebar stuff
</div>
</div>
, , 2 . :
$(document).ready(function () {
var highestCol = Math.max($('#leftColumn').height(),$('#rightColumn').height());
$('.elements').height(highestCol);
});
jQuery , 2 . ( )