My site looks fine for pages with long content, but the footer moves up on pages with short content (EDIT: The links now show a working correct sticky footer). I've tried multiple solutions, but I can't get any of them to work (not working here is either the footer isn't sticky, or it appears in the middle of the page). I've tried this solution and this one (I've removed both solutions so I can start fresh). For example, if you go into chrome developer tools or firebug and add height:100%
to the #wrapper div (which is essentially the first step to getting this to work), the height extends past 100% and the footer isn't at the bottom.
The basic div structure is as follows:
<div id="wrapper">
<div id="container">
<div id="content">
<div class="post"></div> <!-- floats left -->
<div id="sidebar></div> <!-- floats right -->
<div style="clear:both"></div> <!-- clear hack -->
</div>
</div>
</div>
<div id="footer"></div>
Here's the CSS for the relevant divs:
html {
height: 100%;
}
body {
min-width:900px;
height: 100%;
}
#container {
height: 100%;
padding: 20px;
background: #f4f4f4;
}
#content {
-moz-border-radius: 11px;
-webkit-border-radius: 11px;
border-radius: 11px;
margin: auto;
width: 80%;
max-width: 1000px;
min-width:800px;
padding: 10px;
background: white;
-moz-box-shadow: 0px 2px 6px 3px #C0C0C0;
-webkit-box-shadow: 0px 2px 6px 3px #C0C0C0;
box-shadow: 0px 2px 6px 3px #C0C0C0;
}
#footer {
padding: 10px;
text-align: center;
box-sizing: border-box;
background: #101010;
height: 14em;
color: white;
}
/* These two are probably less important */
#sidebar {
float: right;
height: 100%;
margin: 15px 25px;
-moz-border-radius: 11px;
-webkit-border-radius: 11px;
border-radius: 11px;
/*IE 7 AND 8 DO NOT SUPPORT BORDER RADIUS*/
-moz-box-shadow: 0px 0px 7px #000000;
-webkit-box-shadow: 0px 0px 7px #000000;
box-shadow: 0px 0px 7px #000000;
/*IE 7 AND 8 DO NOT SUPPORT BLUR PROPERTY OF SHADOWS*/
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#dcedeb');
/*INNER ELEMENTS MUST NOT BREAK THIS ELEMENTS BOUNDARIES*/
/*Element must have a height (not auto)*/
/*All filters must be placed together*/
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#dcedeb')";
/*Element must have a height (not auto)*/
/*All filters must be placed together*/
background-image: -moz-linear-gradient(top, #ffffff, #dcedeb);
background-image: -ms-linear-gradient(top, #ffffff, #dcedeb);
background-image: -o-linear-gradient(top, #ffffff, #dcedeb);
background-image: -webkit-gradient(linear, center top, center bottom, from(#ffffff), to(#dcedeb));
background-image: -webkit-linear-gradient(top, #ffffff, #dcedeb);
background-image: linear-gradient(top, #ffffff, #dcedeb);
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
/*Use "background-clip: padding-box" when using rounded corners to avoid the gradient bleeding through the corners*/
/*--IE9 WILL PLACE THE FILTER ON TOP OF THE ROUNDED CORNERS--*/
}
.post {
width: 100%;
float: left;
height: 100%;
}
Can anyone use something like firebug or CDT to figure out why the height 100% doesn't work and how I can get a sticky footer?
EDIT:
After implementing Ryan Fait's solution as described by @ajkochanowicz, this is how the page looks:
You can see that the grey background (which is the background of the #container div) doesn't stretch to the bottom of the #wrapper div, even though both have height: 100%
.
It's not clear which solution you're using here, so it's hard to tell you what you're doing wrong.
However, I've had success with Ryan Fait's solution and I don't see any of that code here.
If you're not too far into your site development, you can download Kickstrap which has this plugged in and working already.
Otherwise, you'll need to have this CSS
* { margin: 0; }
html, body { height: 100%; }
#wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -142px;
}
#footer, #push { height: 142px; }
Then add the #push
div to your markup as such:
<div id="wrapper">
<div id="container">
<div id="content">
<div class="post"></div> <!-- floats left -->
<div id="sidebar></div> <!-- floats right -->
<div style="clear:both"></div> <!-- clear hack -->
</div>
</div>
<div id="push"></div>
</div>
<div id="footer"></div>
Also don't forget to edit the "142px" value to match your desired footer height.
EDIT To clarify the difference between a fixed and sticky footer, here is a fixed footer: http://jsfiddle.net/y48Su/
And here is a sticky footer implemented with Ryan Fait's solution: http://jsfiddle.net/X6UB7/