I am trying to create a "window", where there is a 'head', 'content' and 'foot' section, the content in all 3 sections can vary, what I am trying to achieve is that the 'head' and 'foot' expand in height to fit their content (could be anything from 0px to 300px) and the 'content' section expands to fill the remaining space in the container. if content of the 'content' box is too big, it should show a scroll bar.
This is what I have so far:
<style>
#container{
position: absolute;
display: table;
width: 500px;
height: calc(100vh - 80px);
top: 80px;
right: 0;
border-spacing: 10px;
background-color: lightgrey;
}
#container > .header{
position: absolute;
display: table-row;
background-color: blue;
width: calc(100% - 20px);
}
#container > .content{
position: relative;
display: table-row;
background-color: green;
}
#container > .footer{
position: absolute;
display: table-row;
background-color: red;
width: calc(100% - 20px);
bottom: 10px;
}
</style>
<div id="container">
<div class="header"> </div>
<div class="content"> </div>
<div class="footer"> </div>
</div>
Ultimatly I would like to have the content scroll BEHIND the header and footer but that would require adding margin/padding to the content box on top and bottom but the header and footer heights are unknown.
If I have to resort to java-script to achieve this (get height of header and footer then set content height) I will but would prefer to do it with CSS.