Is there a method I can use for a div to extend to full height? I've got a sticky footer in it as well.
Here's the web page: Website removed. The middle bit I'm talking about is the white div, midcontent which has CSS values:
.midcontent{
width:85%;
margin:0 auto;
padding:10px 20px;
padding-top:0;
background-color:#FFF;
overflow:hidden;
min-height:100%;
max-width:968px;
height:100%;
}
So yes, obviously height:100%
didn't work. Additionally, ALL parent containers have height set.
Here's the general structure
<body>
<div id="wrap">
<div id="main">
<div class="headout">
<div class="headimg"></div>
</div>
<div class="midcontainer"></div>
</div>
</div>
<div id="footer">
<div class="footer"></div>
</div>
This is an old question. CSS has evolved. There now is the
vh
(viewport height) unit, also new layout options likeflexbox
orCSS grid
to achieve classical designs in cleaner ways.In case also setting the height of the html and the body to 100% makes everything messier for you as it did for me, the following worked for me:
The - 33rem is the height of the elements coming after the one we want to take full height, i.e., 100vh. By subtracting the height, we will make sure there is no overflow and it will always be responsive (assuming we are working with rem instead of px).
Did you remember setting the height of the html and body tags in your CSS? This is generally how I've gotten DIVs to extend to full height:
if setting height to 100% doesn't work, try min-height=100% for div. You still have to set the html tag.
This might be of some help: http://www.webmasterworld.com/forum83/200.htm
A relevant quote: