Equal Height 2.0

Created Tuesday 16th of September 2008 by Andreas Lagerkvist
Copyright © 2008 Andreas Lagerkvist (andreaslagerkvist.com)

What it Does

This plug-in makes HTML-elements equal height by adjusting their min-height CSS properties. Of course IE6 has no clue what min-height means so the plug-in uses height for that crappy old dinosaur.

How to Use

jQuery('#content, #secondary-content').equalHeight(); would make the elements with IDs 'content' and 'secondary-content' equal height.

Example

Hi

Hi
Bye!

Example Code

HTML

<div id="jquery-equal-height-example">
<
p>Hi</p>

<
p>Hi<br />Bye!</p>
</
div>

JS

jQuery('#jquery-equal-height-example p').equalHeight();

Source Code

jQuery.fn.equalHeight = function () {
    var 
height        0;
    var 
maxHeight    0;

    
// Store the tallest element's height
    
this.each(function () {
        
height        jQuery(this).outerHeight();
        
maxHeight    = (height maxHeight) ? height maxHeight;
    });

    
// Set element's min-height to tallest element's height
    
return this.each(function () {
        var 
t            jQuery(this);
        var 
minHeight    maxHeight - (t.outerHeight() - t.height());
        var 
property    jQuery.browser.msie && jQuery.browser.version 'height' 'min-height';

        
t.css(propertyminHeight 'px');
    });
};

Download

Plug-in

Requires

blog comments powered by Disqus

Random jQuery Plug-ins

  • Text Shadow

    Frankly a rather crappy text-shadow plug-in (can one be done well? :) but nevertheless it does the job in some cases.

    Details

  • Image Zoom

    This plug-in makes links pointing to images open in the "Image Zoom". Clicking a link will zoom out the clicked image to its target-image. Click anywh...

    Details

  • Ajax Loader

    Use this plug-in when you want to inform your visitors that a certain part of your page is currently loading. The plug-in adds a faded 'loading-div' o...

    Details

More Plug-ins

Recent Comments

Powered by Disqus
Page cached. Loaded in: 0.8454 second(s).
Last DB change: 2012-04-02 11:06:05
Last file change: 2012-04-25 20:30:39
Cache created: 2012-05-18 02:17:03