Saturday, October 8, 2011

Use Javascript to make two columns the same height


Our web site needed the left and right columns to be the same height because of the background color. We use this simple script which is loaded from an external file.

var x = document.getElementById("column_l").clientHeight;
var y = document.getElementById("column_r").clientHeight;
if (x > y)
document.getElementById("column_r").style.height = x + 'px';
if(x < y)
document.getElementById("column_l").style.height = y + 'px';

No comments:

Post a Comment