Avoid using hacks
Do not hard code the solution. The goal is to create a solution that works for dynamic content and responsive screen sizes, rather than just one specific case.
The issue lies in the fact that the headers are not direct children of the elements they need to match heights with.
Find the codepen here:
https://codepen.io/anon/pen/OxzrzV
HTML
<h1>disclaimer: resize the window. Make the blue headers in a row match height</h1>
<div class="row mycontainer">
<div class="col-12 col-md-4 col-lg-3">
<div class="item">
<div class="header">bippo</div>
<div class="content">some content lala some content lala </div>
</div>
</div>
<div class="col-12 col-md-4 col-lg-3">
<div class="item">
<div class="header">bippo</div>
<div class="content">some content lala </div>
</div>
</div>
<div class="col-12 col-md-4 col-lg-3">
<div class="item">
<div class="header">bippo</div>
<div class="content">some content lala </div>
</div>
</div>
<div class="col-12 col-md-4 col-lg-3">
<div class="item">
<div class="header">bippo</div>
<div class="content">some content lala </div>
</div>
</div>
<div class="col-12 col-md-4 col-lg-3">
<div class="item">
<div class="header">bippo</div>
<div class="content">some content lala some content lala some content lala </div>
</div>
</div>
<div class="col-12 col-md-4 col-lg-3">
<div class="item">
<div class="header">oh no this header wraps</div>
<div class="content">some content lala </div>
</div>
</div>
</div>
CSS
body{
padding: 20px;
}
.item{
height: 100%;
padding-right: 20px;
padding-top: 20px;
display: flex;
flex-direction: column
}
.header{
background-color: cornflowerblue;
}
.content{
background-color: salmon;
flex-grow: 1;
}
.mycontainer{
max-width: 500px;
}
What am I looking for?
I want the blue headers to always have the same size as all elements in the current row.
A reliable jQuery solution is acceptable, as long as it works seamlessly on resizing. A change in the HTML structure is also welcome if it ensures responsiveness.
Here is an example of what I want to achieve (without hard coding and being responsive):