Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery: can't work out how to implement equal column height script
    primarykey
    data
    text
    <p>Just a little edit, in case it helps anyone out who happens to stumble upon this. The answer given worked perfectly until I added some images. The images I added have no set width or height and have max-width 100% css applied to them so they scale within a fluid grid. Problem seems to be chrome was not adding the height of the images to the total column heights so the columns were being rendered to short ( minus the images height )</p> <p>Changing the line of code:</p> <pre><code>$(document).ready(function(){ </code></pre> <p>to</p> <p>$(window).load(function() {</p> <p>Seems to fix the problem.</p> <p>------------ original question ----------------</p> <p>I'm trying to implement this jquery code I came across <a href="http://www.broken-links.com/2009/01/20/very-quick-equal-height-columns-in-jquery/" rel="nofollow">here</a>; I can't for the life of me figure out how to get it working though.</p> <p>I've included a link to jQuery in my document and tried various options but I can't get it working.</p> <p>My page is a html5 2 column layout, with the 2 columns set with % widths and floated. The content of left column is long so I would like them to be equal.</p> <p>I'm guessing I need to add the class <code>unevenheights</code> to a div. I've added it to each column and tried it on the wrapper <code>div</code> with no luck.</p> <p>I tried copying to first section to a seperate file and saving as a .js, then linking to that and using the <code>$('div.unevenheights').setAllToMaxHeight()</code> part within <code>&lt;script&gt;</code> tags in the page head but no joy.</p> <p>Could someone please explain in beginner terms how I should implement it?</p> <pre><code>$.fn.setAllToMaxHeight = function(){ return this.height( Math.max.apply(this, $.map( this , function(e){ return $(e).height() }) ) ); } // usage: $('div.unevenheights').setAllToMaxHeight() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload