I've had alot of trouble keeping my footer on the bottom, when my main div is short on content. But I fixed it with the sticky footer trick. But unfortunately I still have this problem where my main div won't stretch all the way down to the footer when it's short on content. I have fixed this with JS by adding an extra div in the empty space if the main div's bottom edge + the footer were smaller than the viewport. But that's no longer an option since i want to support non js users.
html, body {
height: 100%;
background-color: #678dae;
margin: 0px;
padding: 0px;
}
#wrap {
min-height: 100%;
}
#main {
width: 70%;
/* I need them to be centered like this because my div is being resized from time to time */
margin-left: auto;
margin-right: auto;
overflow:auto;
padding-bottom: 150px;
background-color: #fff;
}
#footer {position: relative;
margin-top: -150px; /* negative value of footer height */
height: 150px;
background-color: #333;
clear:both;
}
<div id="wrap">
<div id="main">
<div id="content">
<p>Div content</p>
<!-- <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> -->
</div>
</div>
</div>
<div id="footer">
<p>Footer content</p>
</div>