<div id="top"></div>
<div id="content">Why this div is not 100% height? I need this to fill all the way to the start of the footer if content is to little. If content extends beyond the blue footer, it should push the footer down.
</div>
<div id="anchored-footer"></div>
CSS
* { margin: 0; padding: 0 }
html { height: 100%; }
body {
position: relative;
min-height: 100%; /* to fill screen 100% even with less content */
height: 100%; /* to allocate only 100% height */
}
#top {
height: 50px;
background-color: red;
top: 0;
}
#anchored-footer {
height: 50px;
background-color: blue;
width: 100%;
}
#content {
border: 5px solid green;
background-color: yellow;
min-height: calc(100% - 110px); /* allocate the remaining width except the header + footer + borders */
height: auto;
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.