Navigation Menu
Alphabetical Listing
Site Contents

Site FAQ
About JSS
JavaScript Forum
JavaScript Tutorial
Friends of JSS

Link to Us
JavaScript Help
Contribute a script
Technology Jobs

Become a Partner

Internet.commerce

Be a Commerce Partner


Developer Channel

FlashKit.com
JavaScriptSource
Developer Jobs
ScriptSearch
WebDeveloper.com
Webreference
HTMLGoodies
HTML5 Dev Center
Developer.com
jGuru.com
PHPBuilder

Great Sites

DocJavaScript.com
dhtml.com
The Freebie Directory
TheFreeSite.com

Browse Doc JS's Tips!


Hiermenus Central


Promotions

Free Announcements


Social Bookmark

General

Unequal column heights make CSS layouts difficult to manage when the height of content cannot be known in advance, particularly in scenarios where absolute positioning is in use. While there are a variety of strategies to deal with this issue, here's a jQuery-based fix.


Notes

Using the Plugin

The jQuery library is required.

A call to

$(".jqColumn").vjustify(); 

will do the trick, assuming you've assigned class="jqColumn" to all elements needing vertical justification. Use of the plugin assumes that the browser is able to determine the height of all elements at .vjustify() runtime, which can be a problem in certain scenarios. See the warning below.

Obviously, you can apply .vjustify via any jQuery mechanism for objectifying elements.

Issues and Warning

In Firefox 2.0, at least, $(document).ready() functions are executed before images are actually loaded. In other words, Firefox seems consider the DOM ready for scripting prior to a complete load.

The upshot of this is that any use of vJustify plugin within a $(document).ready() context (a typical jQuery convention) may get the wrong height of any blocks that contain <img> elements that don't explicitly specify their height attribute. .vjustify() works fine in contexts where the height is specified (or known because all elements have fully loaded).

Find out more about this issue and a work around.

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: vjustify.js


Head

Paste this code into the HEAD section of your HTML document.


User Comments

Add a comment, suggestion, or correction
[For questions about usage, consult the Notes tab above or visit the JavaScript forum. Do not include more than two (2) lines of code in your comments. If you have suggestions or corrections, you can submit them to us.]

    
   
       
[optional]
 
[optional]

   

Comments feed Comment Feed RSS 2.0

1. From: Peter McCall
vjustify
11/21/2008 02:22:49

The NOTES part of your write up was very vague for me. Certainly that may be testimony to my lack of years of experience or in-depth knowledge. What would be helpful is example code where a couple or three columns are being "justified" and what the code would look like. For example, where does the code lines go that satisfy the following statements....

A call to $(".jqColumn").vjustify(); will do the trick, assuming you've assigned class="jqColumn" to all elements needing vertical justification.

It would be good to show how to assign the class.

Also not easy to understand was how to load the library.

All of these issues kept me from using the code at this point. I am going to try to use Niftycorners again which I have use 1 time before.

2. From: Lee (Admin)
01/16/2009 10:17:24

I can understand your wanting more information. That is why there is a link to the author's site listed under the "Notes" tab.


Do you write JavaScripts?
If you do, why not submit them to us?
We'll give you credit and a link back to your Web site.