我找到了一个脚本here,它平衡了一行中div的高度(bootstrap)。例如,如何将20添加到它计算的新高度?
这是脚本和jsFiddle: http://jsfiddle.net/MVP3C/
$('.well, .alert').height(function () {
var h = _.max($(this).closest('.row').find('.well, .alert'), function (elem, index, list) {
return $(elem).height();
});
return $(h).height();
});
答案 0 :(得分:2)
请尝试以下代码段:
var HeightIncrement = 20; // the increment you need
var h = _.max($('.row').
find('.well, .alert'),
function (elem, index, list) {
return $(elem).height();
});
var maxHeight = $(h).height();
$('.well, .alert').height(function () {
return maxHeight + HeightIncrement;
});
本质上,只需要预先计算公共高度(maxHeight
变量),然后使用增加的公共高度值运行.height(...)
函数。