2011-08-13 67 views
1

http://shoes4school.project-x.me/get-involved.htmljQuery的高度相等列

有人可以告訴我,我做錯了什麼的jQuery的列人造......我不能讓它嘗試幾種不同的方法後,工作...

我使用的代碼是...我的網址高於

$ j(「。content-block」)。height(Math.max($(「#right」)。height(),$(「 。。內容塊「)的高度()));

+0

列你不應該需要jQuery來創建兩個欄佈局。正確的CSS應該這樣做,沒有JS,是否有一個原因,你只是沒有做傳統的兩列CSS佈局? – Jim

回答

2

如何人造的網頁

(function($){ 
// add a new method to JQuery 

$.fn.equalHeight = function() { 
    // find the tallest height in the collection 
    // that was passed in (.column) 
    tallest = 0; 
    this.each(function(){ 
     thisHeight = $(this).height(); 
     if(thisHeight > tallest) 
      tallest = thisHeight; 
    }); 

    // set each items height to use the tallest value found 
    this.each(function(){ 
     $(this).height(tallest); 
    }); 
} 
})(jQuery); 
+0

當較小的div有邊距或填充時,此答案不起作用。 – angelcervera

0

螢火顯示此錯誤:

preloadImages is not defined 
preloadImages([ 
+0

我修正了那個錯誤,但是列沒有被僞造。我想給你,因爲它是一個快速和加號我正在修改一個joomla模板... – avernon2

+0

此外這種方法已爲我工作無數次...我不知道什麼問題是.. – avernon2

+0

正如我看到它現在在FF6上工作。 –