Last active
October 12, 2017 16:17
-
-
Save gabriel-felipe/6beca139d3d42c1a9cec32238c14efed to your computer and use it in GitHub Desktop.
Small javascript plugin to make objects have the same height
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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