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

Dynamic Drive Blog Here

CSS Equal Columns Height script (v1.01)

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

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

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

One of the solutions is to use min-height css property, but problem is that it is not supported in IE 6.X, and I am not sure for IE 7.x. In firefox it works fine.
But this shouldn't solve mentioned problem, in case that column expand more then min-height, and it that case your script might be one of the best solutions.
Posted by myspacelayouts on 02/13, 02:39 AM
This is very nice site.
Posted by Amol on 02/13, 09:08 PM
I like the way this script works and really makes a page look clean. I have a question. I've got a page that has two sections (top and bottom)for the editable area. I tried having 3 columns in each section but only the first 3 were adjusted to equal heights. My css has 3 styles defined, 1 for each column (lft, ctr and rt). I reuse these in each section. I know I can copy these and rename one set lft2 ctr2 and rt2 and it will most likely work but I didn't want to add the duplicate code to the css.
Any suggestions?
Posted by Wayne on 03/02, 06:12 AM
hai how can i chance my last name from my old url to new name but still showing the same page? example. the 5th page for my website is for registration, so when someone click the REGISTER BUTTON it will show www.perigiduit.com/?ref=fen25. i want to change it to www.perigiduit.com/?ref=sea08. plezzz..i know nothing about website and url.
Posted by sea08 on 03/17, 03:08 AM
Fantastic, solved my problem, too.
Big thanks,

Radek
Posted by Radek on 03/20, 07:14 AM
you can check my blog for equal height of columns using css. Create equal height columns using CSS
Posted by Girendra Singh on 03/21, 12:48 PM
Thanks a lot for this script. Works great!
Posted by Mrbomb on 03/25, 04:37 PM
Love this script, but there's an issue with printing using an alternate layout (with the "columns" in sequence rather than side by side) -- it still makes the shorter column the same length, wasting a lot of paper. Has anyone figured out a way to disable the equalcolumns.js when the page is printed?
Posted by PaulPSP on 03/31, 02:14 PM
It doesn't work for me, wonder what's wrong. I have it here http://projects.kuzzuk.net/dr_corey/
Posted by Dipankar on 03/31, 06:19 PM
I see the code working on one of my columns, but not the column "contentleft" in my page. I have edited the .js so it is looking for the "contentleft" id, but it is unaffected. Any suggestions? Thanks!
Posted by Steve on 04/03, 08:05 AM

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

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