2013-06-03 48 views
0

我擁有均衡div的代碼,但是我對「返回原始高度「部分。當窗口大小大於指定寬度時,在兩個浮動div上均衡高度,然後在窗口寬度低於時返回到原始高度

下面的代碼我到目前爲止:http://jsfiddle.net/5fTXZ/1/

jQuery的:

// equalize height of columns 
function equalHeight(group) { 
    tallest = 0; 
    group.each(function() { 
     thisHeight = $(this).height(); 
     if (thisHeight > tallest) { 
      tallest = thisHeight; 
     } 
    }); 
group.height(tallest); 
} 

// change to original height of columns 
function originalHeight(group) { 
    // not sure what to put here 
} 

// change height based on windows size 
function checkWindowSize() { 
    if ($(window).width() > 767) { 
     equalHeight($(".col")); 
    } else { 
     originalHeight($(".col")); 
    } 
} 

jQuery(document).ready(function ($) { 
    $(window).resize(checkWindowSize); 
    checkWindowSize(); 
}); 

如果你改變了輸出的div一定的高度相等時寬度大於窗口的大小,您可以看到767px。如果你將它改回到767px的寬度以下,它只會調用我還沒有弄清楚的空函數。

回答

相關問題