JSFiddle - React, Tailwind, and code Playground
HTML
<h1>How to get the <code>.bar</code> container to match the height of the overflowed <code>.foo</code> div using <code>flex</code>?</h1>
<input type="radio" id="flex" name="solutions" checked="checked"><label for="flex">Flex solution?</label>
<input type="radio" id="grid" name="solutions"><label for="grid">Grid solution</label>
<input type="radio" id="table-cell" name="solutions"><label for="table-cell">Table-cell solution</label>
<div class="outer">
<div class="col foo">
foo
</div>
<div class="col bar">
bar
</div>
</div>
SCSS
* {
box-sizing: border-box;
}
#flex:checked {
~ .outer {
display: flex;
align-items: stretch; /* the default, but placed here anyway */
}
}
#grid:checked {
~ .outer {
display: grid;
grid-template-columns: 30px 1fr;
}
}
#table-cell:checked {
~ .outer {
.col {
display: table-cell;
}
}
}
.outer {
border: 2px solid red;
height: 300px;
width: 200px;
overflow: auto;
}
.col.foo {
min-width: 30px;
height: 900px;
border: 2px solid blue;
min-height: 0;
background: rgba(0,0,255,0.1);
}
.col.bar {
width: 100%;
border: 2px solid green;
background: rgba(0,255,0,0.1);
}