JSFiddle - React, Tailwind, and code Playground

HTML

<div class="header">Header
    <div class="sub-header">Sub-Header</div>
</div>
<div class="main-content">Auto adjust size</div>
I want to have the blue div take up the remaining         space in this white space, as well as after the sub-header is removed at the break point.
<div class="footer">footer</div>

CSS

body, html {
    padding: 0;
    margin: 0;
}
.header {
    padding-top: 5px;
    background-color: red;
    width: 100%;
}
.sub-header {
    padding: 5px;
    margin: 0px;
    background-color: yellow;
    width: 100%;
}
.main-content {
    padding: 5px;
    background-color: blue;
    width: 100%;
    position:absolute;
    top:51px;
    bottom:0px;
}
.footer {
    position: absolute;
    bottom: 0;
    padding: 5px;
    background-color: green;
    width: 100%;
}
@media screen and (max-width: 320px) {
    .sub-header {
        display: none;
    }
    .main-content {
        top: 23px;
    }
}
}