Блоки одинаковой высоты при изменении ширины страницы с помощью JS

function makeSameHeight(){
	$('.js-same-height-container').each(function(el, i){
		let maxHeight = 0;

		$(this).find('.js-same-height').each(function(){
			let minHeight = $(this).css('min-height');
			let height = $(this).css('min-height', 0).outerHeight();
			$(this).css('min-height', minHeight);
			if (maxHeight < height) {
				maxHeight = height;
			}
		});

		if (maxHeight > 0) {
			$(this).find('.js-same-height').css('min-height', maxHeight);
		}
	});
}

makeSameHeight();

$(window).on('resize', function(){
	makeSameHeight();
})

Похожие записи

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *