Is there a way to ensure all h2 containers have the same height, both with JavaScript and without it? The h2 titles are dynamic and can vary in length, but I want to maximize the space for all containers.
img {
max-width: 100%;
height: auto;
}
.grid {
display: grid;
grid-template-columns: 25% 25% 25% 25%;
grid-column-gap: 2rem;
}
<div class="container">
<div class="grid">
<div class="items">
<div class="item-title">
<h2>Lorem ipsum dolor sit amet, consectetur adipiscing elit</h2>
</div>
<img src="https://via.placeholder.com/350x150" alt="">
<p>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.</p>
</div>
<div class="items">
<div class="item-title">
<h2>The quick brown fox jumps over the lazy dog.</h2>
</div>
<img src="https://via.placeholder.com/1400x600" alt="">
<p>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.</p>
</div>
<div class="items">
<div class="item-title">
<h2>The color is Green</h2>
</div>
<img src="https://via.placeholder.com/783x512" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div class="items">
<div class="item-title">
<h2>The quick brown fox jumps over the lazy dog.</h2>
</div>
<img src="https://via.placeholder.com/450x273" alt="">
<p>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.</p>
</div>
</div>
</div>
Check out the CodePen Demo: https://codepen.io/rejaulkarim/pen/xaXBLP