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

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

Comment Pages 15 of 18 pages « First  <  13 14 15 16 17 >  Last »

Hi Guys.

Great script, but I'm having a problem with Firefox. My page uses this and another of your scripts (Switch Content). Works fine in IE, but in Firefox the page doesn't resize when you expand content, so it goes off the bottom and onto the background. Any ideas? Here's the page:

http://www.advantagealbania.com/tourism.html
Posted by Sam on 12/18, 03:31 AM
Using this with the css layouts shown on DD it works great!

@Sam did you get that layout at DD? Do you have more than one column in your design?

Nice to be table free and have consistent layout from top to bottom.

Many Thanks...now to hack it to my needs :)
Posted by Brian on 12/20, 01:37 PM
Hi, I wanna know how can some sites adjust the whole aspect of the site to fit with the screen resolution, how can is that possible? using CSS, maybe Java?
Posted by Andrés Karabin on 12/22, 05:45 PM
You put some good stuff in here that helped me a lot with optimizare website
Posted by cori on 12/23, 12:45 PM
Not to take away from the work that was done here... but because of the IE problems I was seeing (not using the layouts here), i decided to use prototype to do the dirty work for me.
Posted by http://www.spotesya.com/<" rel="nofollow">hamdi on 01/03, 02:28 AM
Well, I guess that this problem with the columns can be easily fixed nesting all of them on a wrapper div without needing to use js at all
Posted by azmodan on 01/08, 11:01 PM
this script worked amazingly... but i am using it for content boxes... so when i add another set below the original 1st two coloumns.. they are not resized... can u please tell me wht to do in order for it to resize all content boces set tht may follow below...
Posted by Harsha on 01/13, 10:18 PM
Ok what I would like to accomplish is for all of my columns to be the same height - however I don't want to dictate a height - for example in a three column layout - say the content runs taller than 400px - if I use that script it only makes the side columns 400px even though the content box got bigger to hold the content so the content box still ends up being larger than the side columns... How to I... um... anchor the bottom of each column (left, content, right) to the bottom of the wrapper?
Posted by Zox on 02/07, 02:57 PM
I am using the CSS file as a external file with contentcolumn and rightcolumn as class. When I use the equalcolumn script it doesnt work. Is using the divs as class the problem ? How to make it work ?
Posted by Vignesh on 02/12, 07:00 AM
Absolute rubbish, this script is buggy in IE and Firefox, and incompatible with frequently used CSS positioning techniques. It should be removed from the site.
Posted by zeke on 02/12, 03:00 PM

Comment Pages 15 of 18 pages « First  <  13 14 15 16 17 >  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