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: 209

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 (209)

Comment Pages 18 of 21 pages « First  <  16 17 18 19 20 >  Last »

Do some searches via google and yahoo and you will find ways that this can be done in a much cleaner fashion via CSS alone (i.e., without the use of javascript).
Posted by Michael on 07/01, 08:47 AM
Hey guys a real life saver. Because of this script I am going to know code my websites in XHTML rather than HTML with tables as I wanted to achieve equal hight columns. Thanks a lot!
http://website-design-london.blogspot.com/
Posted by free vector computer on 07/17, 09:22 PM
I tried this on as many as 10 different sites and it worked great. I do have a few of the DD templated fluid layouts that I modified and they worked good in those also. Thanks.
Posted by Ron on 07/25, 12:43 PM
Great little script but I forgot to add, can you also now teach my wife how to cook.
Posted by Ron on 07/25, 12:55 PM
Thanks to this script, I was able to solve a complex layout problem. The CSS methods people advocate is not straight forward and messy.

This script worked like a breeze!
Posted by Hinduism on 08/07, 05:08 AM
Thats great I have always thought of css as nuts and why do people prefer it to table any way now atleast there is one problem that is solved.
Posted by Jamal Panhwar on 09/07, 09:36 AM
You should never use javascript to do these kind of fixes. There's already a clean workaround with css only.

http://www.positioniseverything.net/articles/onetruelayout/equalheight
Posted by Mitchell on 09/27, 02:47 PM
Thanks, very helpful script but I'm having problems with IE6 as well...

(script being called incesstantly by IE6)

I gave the CSS Liquid Layout #2.1- (Fixed-Fluid) at try

The code can be found here...
http://www.jhgraphics.com/out/

Possible work-arounds?....Any help would be appreciated. Thanks!
Posted by Jo on 10/01, 07:32 PM
Thanks for the script, it works really well. :)
Posted by COil on 10/08, 01:58 PM
Thank you so much for this script :)
boating holidays
Posted by boating holidays on 10/09, 12:23 AM

Comment Pages 18 of 21 pages « First  <  16 17 18 19 20 >  Last »

Commenting is not available in this weblog entry.
Sponsors

Advertise Here

Copyright 2006-2011 Dynamic Drive Read our Usage Terms before using any of the CSS codes.