Oftentimes, I find myself wanting to create a clean and simple web page layout using flexbox. Here's an example of what I'm aiming for:
https://i.sstatic.net/0xYX5.png
Here is the code snippet I have tried so far:
.container {
height: 100vh;
display: flex;
flex-wrap: wrap;
}
.header {
height: 40px;
background-color: red;
width: 100%;
}
.sidenav {
background-color: blue;
align-items: flex-start;
}
.main {
background-color: green;
flex-grow: 1;
}
<div class="container">
<header class="header">Header</header>
<nav class="inner sidenav">Sidenav</nav>
<div class="inner main">Main</div>
</div>
I've encountered an issue where there is a blank space between the header and the other elements when I set the height of the .header
. Can anyone explain why this happens and offer a solution to fix it without adding extra wrappers?