I have a flexbox layout in my app similar to the snippet below, a set of li
s with three div
s in each
.container {
width: 500px;
}
ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
}
li {
border: solid 1px black;
flex: 1;
}
.title {
border: solid 1px red;
margin-bottom: 1em;
}
.content {
border: solid 1px yellow;
margin-bottom: 1em;
}
.footer {
border: solid 1px blue;
}
<div class="container">
<ul>
<li>
<div class="title">
Blah Blah Blah Blah Blah Blah
</div>
<div class="content">
Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah
</div>
<div class="footer">
Some other stuff here
</div>
</li>
<li>
<div class="title">
Blah Blah Blah Blah Blah Blah
</div>
<div class="content">
Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah
</div>
<div class="footer">
Some other stuff here
</div>
</li>
<li>
<div class="title">
Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah
</div>
<div class="content">
Blah Blah Blah Blah Blah Blah Blah Blah
</div>
<div class="footer">
Some other stuff here
</div>
</li>
</ul>
</div>
I'm looking to have the children divs start at the same level across the times, e.g. the yellow div tops are equal, and the blue div tops are equal. Previously I've done this by making the children divs absolute positioned, and then have them be fixed height, with fixed tops. However, doing this, I have to set the heights based on the guessed maximum size of the text they will contain, which, when combined with the page being responsive (There is single breakpoint where it goes from side by side columns to a carousel), this can lead to a lot of empty space in the columns.
Most examples I've found (as I apparently don't really know the right terms to google this...) involve either Javascript, or rearranging the markup to have the rows at the top of the hierarchy, instead of the columns. I would like to stick with columns, they're set up to handle the cases of 1, 2, or 3 columns, and also serve as a carousel on small devices.
Am I missing how to do this, or am I stuck with Javascript?