Is flexbox the best thing to use in this situation?
Yeah, it's a good idea to use flexbox in this situation.
To achieve your desired result, as I understand, you need to set height: 100%
on #container
so that it occupies all the space available to it. Then set flex-grow: 0
on .bottom
so that it doesn't grow.
So your CSS should be:
#container {
width:100%;
height:100%;
background:grey;
display:flex;
flex-direction:column;
}
.top {
background:red;
flex: 1 0 auto; // Grow, don't shrink
padding:20px;
}
.bottom {
background:yellow;
flex: 0 0 auto; // don't grow, take up only needed space
padding:20px;
}