2016-02-26 121 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