I'm Looking to create two containers besides each other, taking up the entire width (distributed through flex
) and having the same height. The left one should grow its height with its content, the right one should always be exactly the same height as the left one, scrolling it's content when necessary.
The structure looks like this. Currently the right column grows the left column (and parent container), which shouldn't happen. Obviously max-height
doesn't have any effect here, as the reference is the parent div
. How can I make this work?
.container {
display: flex;
}
.col1 {
flex: 1;
background: #999;
}
.col2 {
flex: 2;
background: #F00;
max-height: 100%; /* max-height should be height of left column */
overflow: auto;
}
<div class="container">
<div class="col1">
this<br>
div<br>
should<br>
grow<br>
based<br>
on<br>
content
</div>
<div class="col2">
this<br>
div<br>
should<br>
never<br>
exceed<br>
the height<br>
defined by the left one<br>
(which happens with this row)<br>
it should scroll instead
</div>
</div>