Skip to content

Instantly share code, notes, and snippets.

@xto3na
Last active July 15, 2019 06:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xto3na/1600495537d7de5b86a5 to your computer and use it in GitHub Desktop.
Save xto3na/1600495537d7de5b86a5 to your computer and use it in GitHub Desktop.
Выравнивание всех блоков по размеру
(function($){
function equalizeHeights(selector) {
var heights = new Array();
// Loop to get all element heights
$(selector).each(function() {
// Need to let sizes be whatever they want so no overflow on resize
$(this).css('height', 'auto');
// Then add size (no units) to array
heights.push($(this).height());
});
// Find max height of all elements
var max = Math.max.apply( Math, heights );
// Set all heights to max height
$(selector).each(function() {
$(this).css('height', max + 'px');
});
$('.all-tabs-wrapper').css('height', max + 'px');
}
$(window).load(function() {
// Fix heights on page load
equalizeHeights('.tab-content');
// Fix heights on window resize
$(window).resize(function() {
// Needs to be a timeout function so it doesn't fire every ms of resize
setTimeout(function() {
equalizeHeights('.tab-content');
}, 120);
});
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment