I am trying to build a sidebar that takes up 100% of the browser's height. Inside this sidebar, there are two divs that will be changing in size depending on the content inside.
<div class="sidebar">
<div class="child-1"></div>
<div class="child-2"></div>
</div>
https://i.stack.imgur.com/ffEQd.png (Sorry, I did my best to show an example)
As you can see, The sidebar starts out with child-2
taking up about 80% of the height (even if its content doesn't fill up the div) and child-1
only taking up about 20% of the height. However, as child-1
's content grows, child-2
gets smaller. If child-2
's content overflows, I will probably be using overflow-y: scroll
in order to be able to contain its content. Likewise, once child-1
reaches a max-height
, I want it to be able to vertically scroll as well.
I can't quite wrap my head around how to do this and handle the changing heights with only CSS. Any help or direction is appreciated. Thanks!