I’m trying to make my footer stick to the bottom of the page. I know, I know there are milions of tutorials on google… believe I’ve gone through most of them. Problem I have is that as soon as I set my html, body to height 100% I automatically get a scroller and the footer gets pushed way down even though there is no content. I’ve tried doing negative margins but that only pulls the footer higher and the scroller still stays the same, with empty space after the footer. Here is my code:
CSS:
html, body {height: 100%;}
div#container {min-height: 100%; margin: 0px auto 0px;}
div#footer{background: #333;height: 140px; position:relative; margin: 0px auto 0;}
HTML:
<body>
<div id=“container”>
<p>text1</p>
</div>
<div id=“footer”>
<p>text2</p>
</div>
</body>
Any help would be greatly appreciated. This is my second day trying to figure this out, so thanks in advance.
The code Ryan posted is the basic structure for Sticky Footers but it did not include the fixes for IE8 and Opera. They both suffer from a min-height:100% bug which causes the footer to hang when the viewport is resized.
Thanks guys for your replies. Finally after two days I got. Your examples helped although I tried something similar before. The thing with my site is that it 's runnning on a custom wordpress theme and there is a lot of margins and paddings. Problem was that I had to not just subtract the height of the footer, but all of the margins included in all the elements + the height of the header. So thanks again for your help.
Do any of you guys have some experience with WP? What would be best way to have the footer stick to the bottom of all the pages. e.g header.php, index.php, and all etc. I know I could just have each page wrapped but wondering if there’s maybe a smarter solution for it.