I am trying to match the height of each slide based on the highest one. I see that I can use “offsetHeight”, but that is a set of height when the code load. I want to make it fixable when the window/outer div change (I am using flexbox for the outer)
$(document).ready(function() {
var offsetHeight = document.getElementsByClassName('highest').offsetHeight;
$('carousel > div').style.height = offsetHeight + 'px';
});
.carousel-wrap {
display: flex;
flex-wrap: wrap;
}
.carousel>div {
background-color: #E3E3E3;
margin: 10px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="carousel-wrap">
<div class="carousel">
<div class="band slide1">1</div>
<div class="band slide2" id="highest">2 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
<div class="band slide3">3</div>
</div>
</div>
I put a resize function after, but somehow it did not work when I resize the window. The .carousel .band did not clear up the inline height and put in a new one.