I'm trying to get a sticky footer at the bottom of a div that has dynamic height (growing content). The div needs to float in the middle of the page (same distance from left and right).
I have the following HTML (stripped of irrelevant stuff):
<html>
<body>
<div class="bodybackground">
<div class="container"><!-- floats in the middle -->
<div class="mainContainer"><!-- different color etc -->
<!-- content with dynamic height -->
</div>
<footer class="pagefooter"></footer>
</div>
</div>
</body>
</html>
and the following CSS (also stripped of the irrelevant stuff):
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; /* needed make it float in the middle of body */
top: 0px;
position: relative;
padding: 0px;
padding-bottom: 158px; /* height of footer */
}
.mainContainer {
position: absolute;
height: 100%;
overflow: auto;
}
.pagefooter {
position: absolute;
bottom: 0px;
margin: 0px;
padding: 0px;
height: 158px;
}
Yet the content of mainContainer floats out and continues behind the footer - instead of the footer being at the very bottom. I have tried just about everything I could find except the examples that force me to change the display property of container, as I needed that to keep it floating in the middle.
Any clues on where I'm being an idiot? Thanks!!
I needed to fiddle a bit more with the .push, but that solved the problem! Thanks for the quick answer!