我想做的是,如果该行div
较大,则该行的所有其他项目都将具有相同的高度。例如,这里是问题所在:http : //i.imgur.com/40RJRt0.png
这是标记:
<div class="box clearfix">
<div class="col-lg-4 col-md-6 col-xs-12 col-sm-6">
<div class="col-lg-4 col-md-6 col-xs-12 col-sm-6">
<div class="col-lg-4 col-md-6 col-xs-12 col-sm-6">
</div>
.col-lg-4{
width: 33.33333333333333%;
float:left;
height: 100%;
}
高度100%不起作用,因为它们是浮动元素。我该如何解决?
你可以做这样的事情
的HTML
<div class="box clearfix">
<div class="col-lg-4 col-md-6 col-xs-12 col-sm-6"></div>
<div class="col-lg-4 col-md-6 col-xs-12 col-sm-6"></div>
<div class="col-lg-4 col-md-6 col-xs-12 col-sm-6"></div>
</div>
Java脚本
$(function () {
$('div.box').each(function () {
var maxHeight = 0;
$('div', this).each(function () {
if (maxHeight < $(this).outerHeight()) maxHeight = $(this).outerHeight();
}).css({
'height': maxHeight
});
});
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句