Edit: That question has been closed by a moderator as a duplicate, but I tend to disagree, the other question is about one element limiting the others. Here any other element than a specific one can be the tallest.
The code is always the easiest way to show a problem: https://codepen.io/Flaburgan/pen/MWbPyjN
I have boxes in a flex layout and they have different height with a dynamic content. All the boxes adapt and have the height of the tallest one, and that is great.
However, I know that one of them can have a lot of content. Thus I would like my boxes to ignore this one, and take the height of the second biggest box. The first one should then see a vertical scroll bar appearing inside it.
How can I achieve this without using fixed height?
<p>The goal is that the green container height doesn't exceed the height of the other boxes, and that a vertical scroll bar appear in it.</p>
<div class="container">
<div class="red">
<ul>
<li>Ours</li>
<li>Chevreuil</li>
<li>Lapin</li>
<li>Loutre</li>
</ul>
</div>
<div class="green overflow">
<ul>
<li>Ours</li>
<li>Chevreuil</li>
<li>Lapin</li>
<li>Loutre</li>
<li>Ours</li>
<li>Chevreuil</li>
<li>Lapin</li>
<li>Loutre</li>
</ul>
</div>
<div class="blue">
<ul>
<li>Ours</li>
<li>Chevreuil</li>
<li>Lapin</li>
<li>Loutre</li>
<li>Loutre</li>
</ul>
</div>
</div>
.container {
display: flex;
}
.container > div {
padding: 0 1rem;
margin: 1rem;
/* This would make it works, but I don't want a fixed value
but the height of the second biggest box
max-height: 200px;*/
}
.overflow {
overflow: auto;
}
.red {
background-color: #fcc;
}
.green {
background-color: #cfc;
}
.blue {
background-color: #ccf;
}
ul {
padding: 0;
list-style: none;
}
li {
padding: 0.5rem;
}