Advanced Search Usage Terms Submit Contact
Dynamic Drive CSS Library
 
CSS Library
Submit an original CSS code
CSS Layouts
Web Graphics
Online Tools:
Last commented:

Dynamic Drive Blog Here

CSS Equal Columns Height script (v1.01)

Date: 11/02/2006 | By ddadmin | Comments: 197

A common pitfall of a CSS based columns layout is that the columns do not share a common height. Unlike a table based layout where the height of the table itself dictates the height of all of its columns, CSS columns are independent of one another in that respect. Now, this can be problematic (from a design standpoint) when you wish to style one of your CSS columns in a way that should extend all the way down to the end of the layout, such as giving a side column an explicit background color, a surrounding border etc.

This is a generic "CSS Equal Columns Height" script that will dynamically set the participating columns' heights to that of the tallest column's height, creating a uniform columns height layout. Use this script on any of our CSS Layouts for example. It's a matter of plug and play! To use this script, just insert this line of code into the HEAD section of your CSS layout page:

<script src="equalcolumns.js" type="text/javascript"></script>

As you can see, it references the external .js file "equalcolumns.js", which you should download (right click and select "Save As") and then upload to your own site.

This script is configured by default to automatically work with all of the layouts in our CSS Layouts section, whether 2 columns or 3 columns, fluid or fixed. Just add the script to the HEAD of any of these pages, and that's it!

If you wish to use this script to equalize the columns of your own custom CSS layout, open up "equalcolumns.js", and refer to the line:

ddequalcolumns.columnswatch=["leftcolumn", "rightcolumn", "contentwrapper"]

Change "leftcolumn", "rightcolumn" etc to the IDs of the CSS columns you wish to equalize. The script will do a check first to see if each corresponding column actually exists.

Your Comments (197)

Comment Pages 13 of 20 pages « First  <  11 12 13 14 15 >  Last »

Thanks, that script is a lifesaver! I've been hunting for something like this forever!
Posted by projekty domow on 10/22, 02:13 PM
Can anyone write the code for that!
Posted by gan on 10/23, 04:08 AM
Fix for the permanent resize problem (hopefully):
Not yet tested, just conceptually.

At the beginning of ddequalcolumns.setHeights set

this.lock=true

and at the end of setHeights (or a few hundred ms later)

this.lock=false

In ddequalcolumns.resetHeights check whether resizing is locked:
if (!this.lock) this.setHeights("reset")
Posted by ardik on 10/24, 01:16 PM
Thank You Very Much.
Your excellent script just solved my problem. Thanks again!
Posted by Gabor on 10/25, 12:33 PM
I read it and i think you right.
Posted by sohbet on 11/01, 10:56 AM
Script works great to equalize the column heights on my site but for some reason the background color for each column is not applied to the extended length. The correct colors are applied to the original length, but the 'filler length' reverts back to the general background and not the one defined for each div. Anyone else run into this?
Posted by R Shea on 11/03, 04:54 AM
thx for the great stuff. keep up your nice work! 10 points!
Posted by Glucosamin Knochen on 11/08, 03:06 AM
Please give me advanced css tapics
Posted by suresh on 11/08, 03:46 AM
if it was only non problematic on IE6..
(same happens to me as Michael above)
Posted by orla wren on 11/10, 04:03 AM
Hi..Iam trying to learn to make blog web page...can anyone please help me provide the script for it....
Posted by Saurabh on 11/14, 02:12 AM

Comment Pages 13 of 20 pages « First  <  11 12 13 14 15 >  Last »

Name: (Required)

Email: (Required)

(NOT shown on page)

URL:

(Shown on page if entered)

Comments: (Required)

Supported BB codes: [b], [i], [u], [em], [strike], [strong], [pre], [code], and [blockquote].

Remember my personal information
Notify me of follow-up comments?

Submit the word you see below:


Sponsors

Advertise Here

Copyright 2006-2008 Dynamic Drive Read our Usage Terms before using any of the CSS codes.
Dynamic Drive DHTML and CSS Code Library