Is it possible to use calc() function of css3 for the following usecase? I have a header having certain padding and then I have bottom having buttons. The header height and the bottom height is fixed, however the content height which is in between header and bottom needs to be dynamic based on what height we provide to the container
ex:I'm using the calc() to calculate the height based on the main
class.
CSS:
.header {
height: 30px;
background-color: red;
padding: 20px 54px;
}
.bottom {
height: 40px;
background: green;
padding: 60px 54px;
}
.middle-content {
background: blue;
padding: 20px 54px;
height: calc(100% - (300-200)+"px");//height of main class div - (header + bottom)//is this possible to calculate this way
}
.main {
border: 2px solid #000;
width: 100%;
}
html:
<div class="main" style="height:400px">
<div class="header">the header height is fixed and cannot be changed</div>
<div class="middle-content">this div needs to grow/shrink depending on what height we enter in the inline style of "main" class to match up to the height of the main class</div>
<div class="bottom">
the bottom height is fixed and cannot be changed
<button>
Trext1
</button>
<button>
Text333
</button>
</div>
</div>
fiddle: https://jsfiddle.net/95j04gdz/2/
from the fiddle you can see there is a white space that needs to be filled correctly by the blue div to match up to the height of main div. Any ideas??