I'm trying to prevent a flexbox child from overflowing it's container, but using overflow:auto on a child div doesn't seem to work.
My basic setup: I have a flexbox container with 2 divs, A and B. The A div has 2 internal divs, A1 and A2, and the B div only has one internal div B1. I'm trying to keep A1 and B1 static, and show a scrollbar on A2 when it overflows.
html:
<div class="wrap">
<div class="A">
<div class="A1">A1</div>
<div class="A2">A2</div>
</div>
<div class="B"><div class="B1">B1</div></div>
</div>
css
.wrap {
display: flex;
flex-direction: column;
Height: 400px;
justify-content: space-between;
background-color: gray;
}
.A {
display: flex;
flex-direction: column;
flex: 1, 1, auto;
}
.B {
display: flex;
flex-direction: column;
flex: 0, 0, auto;
}
.A1 {
background-color: yellow;
flex: 0, 0, auto;
}
.A2 {
background-color: green;
flex: 1, 1, auto;
overflow: auto;
height: 800px;
}
.B1 {
background-color: blue;
flex: 0, 0, auto;
}
Here's a code example: https://codepen.io/guybarn/pen/QWvWVMb