I am trying to get a sticky footer at the bottom of a div that has dynamic height (growing content). The div should float in the middle of the page (same distance left and right).
I have the following HTML (devoid of unnecessary things):
<html> <body> <div class="bodybackground"> <div class="container"> <div class="mainContainer"> </div> <footer class="pagefooter"></footer> </div> </div> </body> </html>
and the following CSS (also devoid of unnecessary material):
html { height: 100%; margin: 0px; padding: 0px; } body { margin: 0px; height: 100%; } .bodybackground { height: 100%; min-height: 100%; } .container { min-height: 100%; display: inline-block; top: 0px; position: relative; padding: 0px; padding-bottom: 158px; } .mainContainer { position: absolute; height: 100%; overflow: auto; } .pagefooter { position: absolute; bottom: 0px; margin: 0px; padding: 0px; height: 158px; }
However, the contents of mainContainer pops up and continues beyond the footer - instead of the footer located at the bottom. I tried everything I could find, except for the examples that make me change the display property of the container, since I need it so that it floats in the middle.
Any clues about where I am an idiot? Thanks!!
I needed to play a little with .push, but this solved the problem! Thanks for the quick response!
source share