Skip to content

Instantly share code, notes, and snippets.

@juliomoreira666
Forked from gabriel-felipe/equalheights.js
Created October 12, 2017 16:17
Show Gist options
  • Save juliomoreira666/d9638ed0cf439f5fd9ce1d52b53eb038 to your computer and use it in GitHub Desktop.
Save juliomoreira666/d9638ed0cf439f5fd9ce1d52b53eb038 to your computer and use it in GitHub Desktop.
Small javascript plugin to make objects have the same height
/*
Usage example:
$(".list > .col-md-4").equalheights();
*/
(function ( $ ) {
$.fn.equalheights = function() {
var maxHeight = 0;
this.each(function(i){
if(parseInt($(this).outerHeight()) > maxHeight){
maxHeight = parseInt($(this).outerHeight());
}
});
this.each(function(i){
height = parseInt($(this).outerHeight());
diff = maxHeight - height;
$(this).css("height",(height+diff)+"px");
});
var selector = this.selector;
};
}( jQuery ));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment