Can you be a bit more precisely? For me it's working just fine in your Codepen. Or is the pink background (which shows some black on large screen) the problem?
One advice, probably not your solution:
Flexbox is used to define the layout. I see that you give the body a flex-direction: row, and you give some elements a fixed height.
Instead of using
.bottom {
height: 40px;
}
I recommend using:
flex: 0 0 40px;
The results are the same, but it could prevent little bugs or weird behaviour in the future. Same goes for your div class=top.
Regarding your problem, try the following:
body {
display: flex;
flex-direction: column;
}
.top {
flex: 0 0 40px;
}
.content {
flex: 1;
overflow-y: scroll;
}
.bottom {
flex: 0 0 40px;
}
Make sure your .top, .bottom and .content are the only and direct children in your HTML. Otherwise this won't work.
This way the top and bottom bar are fixed, and your content fills up the space inbetween.
EDIT:
To vertically align the content within the <div class="content">
, you should add this to your css. (Along with the code above)
.content {
flex: 1;
overflow-y: scroll; //only if you want fixed footer
display: flex;
flex-direction: row; //column should also do fine, since you only have one child element
justify-content: center;
align-items: center;
}
.content-inner { //the only and direct child of content
margin: auto;
}