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 8 of 21 pages « First  <  6 7 8 9 10 >  Last »

It's work fine in IE and FF, but you can delete the target "height:100%" in the layers to work OK in Firefox.

Thank you for the library is very good.
Posted by Antonio on 07/15, 06:22 PM
This didn't work with me,
Posted by Psyphil on 07/24, 06:50 AM
Thanks man, just what I was looking for. Worked like a charm Thanks so much.
Posted by LinkDir on 07/31, 02:46 PM
Wow! what a decision! we'll test it tomorrow for our 3 equal columns layout. Thank you...
Posted by mucicman on 08/01, 11:19 AM
I'm having problems with IE7 and wasn't sure if there was a fix. The footer div messes up. You can't view it. When you scroll down it'll bounce back up UNLESS there is content all the way down to it.

http://www.jswick.com/clients/Reeverian/
Posted by Jesi on 08/03, 09:35 AM
Awesome, been looking for ways to make all columns even on a css-based layout. Will 1 use this a lot I am sure!
Posted by Jake on 08/08, 09:44 AM
Great post, there are so many variables to this problem its hard give a general solution. I guess one just has to keep reading on the subject until something 'clicks'.
Posted by link777 on 08/09, 10:15 AM
Thanks for very interesting Article.
Posted by tercüme on 08/09, 10:51 AM
I'm having problems with IE7 and wasn't sure if there was a fix
Posted by Martin on 08/10, 06:16 AM
This is a great post, but it does not yield some of the out-of-the-box issues. This type of strategy is very expensive to take on from a client’s point of view. Considerable research must be conducted and in many cases, money has to be paid for quality ‘under-the-radar’ links.
Posted by Frenk on 08/12, 03:27 AM

Comment Pages 8 of 21 pages « First  <  6 7 8 9 10 >  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.