I have a flexbox with two sections. One of the left (small section) and the second one on the right (large section).
How can I make both sections take up full screen and prevent awkward white space like you see in the image.
Here’s my code global code:
html {
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
}
* {
box-sizing: border-box;
}
Here’s my flexbox container code:
.container {
display: flex;
flex-direction: row;
height: 100%;
min-height: 100%;
}
Here’s my flexbox children code:
.largesection{
padding: 5px;
border-radius: 4px;
height: 100vh;
width: 100%;
background-color: #f6f6f7;
}
.smallsection {
background-color: #fff;
padding-top: 25px;
padding-bottom: 30px;
height: 100vh;
width: 30%;
border-right: 1px solid #e1e3e5;
}
How can I fix this? Also, The samll section on the left side is actually overflowing.
2
Answers
The problem is the height of the
.container
. It is limited to the height of the viewport. When scrolling (as the left.smallcontainer
has an overflow) this results in the "missing" background color at your yellow mark.Setting the container’s children also to
height: 100vh
prevents that your test have success.Solution:
height: auto;
).container
toheight: fit-content;
Here the test sample:
This is a 2-column full-height layout.
You can give it border, padding, etc. to syle it for your purpose.