JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<div class="item">
come content 1
</div>
<div class="item">
come content 2
come content 3
</div>
<div class="item">
come content 4
come content 5
come content 6
</div>
<div class="item">
come content 7
</div>
</div>
CSS
.container {
display: flex;
flex-direction: column;
width: 200px;
}
.item {
border: 1px solid #ddd;
margin: 10px 0;
}
JavaScript
(function ($) {
// preload object array to gain performance
var $items = $('.item')
// run at resize
$( window ).resize(function() {
$.fn.setHeight(0);
});
$.fn.setHeight = function(height) {
// reset to auto or else we can't check height
$($items).css({ 'height': 'auto' });
// get highest value
$($items).each(function(i, obj) {
height = Math.max(height, $(obj).outerHeight())
});
// set the height
$($items).css({ 'height': height + 'px' });
}
// run at load
$.fn.setHeight(0);
}(jQuery));