我有四个boostrap .panel
,每个都有不同的内容。因此,每个面板具有不同的高度。如何将每个面板的高度设置为与高度最大的面板相等?所有面板都有相同的高度?
<div class="promo">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-3">
<div class="panel panel-default">
<div class="panel-heading panel-heading-custom">NEW OPENING</div>
<div class="panel-body">
<img src="images/img.gif" class="img-circle center-block margins" />
<p>To celebrate our new opening, we have sales on many of your favorite items.</p>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-3">
<div class="panel panel-default">
<div class="panel-heading panel-heading-custom">QUALITY ASSURRED</div>
<div class="panel-body">
<img src="images/img2.gif" class="img-circle center-block margins" />
<p>Our products come with a five-year warranty.</p>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-3">
<div class="panel panel-default" id="tallest">
<div class="panel-heading panel-heading-custom">IN-STORE SPECIAL</div>
<div class="panel-body">
<img src="images/img3.gif" class="img-circle center-block margins" />
<p>Take advantage of our new in-store special. You won't be disappointed to find the greatest deals. Now when you buy two or more products, you can get a third product of similar value for free. </p>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-3">
<div class="panel panel-default">
<div class="panel-heading panel-heading-custom">FREE CONSULTATIONS</div>
<div class="panel-body">
<img src="images/img4.gif" class="img-circle center-block margins" />
<p>If you are by our area, we can pay you a visit or you can stop by our office--consultations are entirely free for local members.</p>
</div>
</div>
</div>
</div>
</div>
</div>
答案 0 :(得分:2)
使用每个循环&amp;获得最大高度的全局变量
var maxH = 0;
$('.panel').each(function(){
if($(this).height() > maxH) {
maxH = $(this).height();
}
});
$('.panel').height(maxH);