I'm not being able to make the footer
stay at the page bottom and the subheader
to be just below the header
without spacing, while I can add or remove the content in-between.
.wrapper {
display: flex;
height: 100%;
flex-wrap: wrap;
font-weight: bold;
text-align: center;
}
.header {
background: tomato;
flex-grow: 1;
flex-basis: 100%;
height: 40px;
align-self: flex-start;
}
.subheader {
background: deepskyblue;
margin-bottom: auto;
flex-grow: 1;
flex-basis: 100%;
height: 60px;
align-self: flex-start;
}
.sidebar-wrapper {
background: gold;
height: 100%;
flex-grow: 1;
flex-basis: 20%;
}
.sidebar {
background: purple;
height: 80vh;
top: 15px;
position: sticky;
}
.content {
background: hotpink;
height: 100%;
flex-grow: 1;
flex-basis: 80%;
}
.footer {
background: lightgreen;
height: 40px;
flex: 1 100%;
margin-top: auto;
}
<div class="wrapper">
<div class="header">Header</div>
<div class="subheader">Subheader</div>
<div class="sidebar-wrapper">
<div class="sidebar">
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor
quam, feugiat vitae, ultricies eget, tempor sit amet, ante.
</div>
</div>
<div class="content">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor
quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean
ultricies mi vitae est. Mauris placerat eleifend leo.</p>
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor
quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean
ultricies mi vitae est. Mauris placerat eleifend leo.</p>
</div>
<div class="footer">
Footer
</div>
</div>
To see the 'misbehavior', just remove the 'sidebar-wrapper' and 'content' elements. Sorry that I can't find a simpler way of describing my problem.