0

I found a script here that equalizes the height of divs in a row (bootstrap). How do you add 20 for instance to the new height it calculates?

Here is the script and a 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();
});
Community
  • 1
  • 1

1 Answers1

2

Try the following snippet:

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;
});

In essence, it is just needed to calculate the common height beforehand (the maxHeight variable), and then run the .height(...) function with an incremented common height value.

http://jsfiddle.net/pJ8zQ/

Andrew Sklyarevsky
  • 2,095
  • 14
  • 17