2016-02-26 289 views
0

我想調整行中的2列。 第一列是最高的,其他列需要擴展到相同的高度。引導行調整大小事件

one row, 3 columns

我測試以下,但它不工作

<div class="row" id="top-row">.... 

$('#top-row').on('resize', function() { /*col-2,3 height = col-1 height*/ }); 

但功能不工作。

+2

'( '調整')'事件適用於'只有window'對象。 –

+2

你怎麼看待用CSS解決這個問題? 'display:table-cell'可以做到完美。 –

+0

您可以在CSS中添加最小高度 –

回答

2
html 
<div class="row"> 
    <div class="col-xs-4"> 
     block 1 
    </div>   
    <div class="col-xs-4"> 
     block 2    
    </div>  
    <div class="col-xs-4"> 
      block 3 
    </div> 
</div> 

JS

$(function() { 
    var $paragraphs = $('#top-row .col-xs-4'), 
    heights = []; 
    $paragraphs.each(function() { 
     heights.push($(this).height()); 
    }); 
    var maxHeight = Math.max.apply(this, heights); 
    $paragraphs.height(maxHeight); 
}); 

這將花費最長塊的高度,將適用於所有

+0

感謝您的例子,它工作正常:-) – Phil795