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

1 Answer 1

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/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.