0

我在这里找到了一个脚本,它可以使连续 div 的高度相等(引导程序)。例如,如何将 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();
});
4

1 回答 1

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(...)以递增的共同高度值运行该函数。

http://jsfiddle.net/pJ8zQ/

于 2012-07-12T05:33:59.703 回答