Search code examples
csslayouthtmlfooter

absolute positioning and css sticky footer


Here is my problem, I am using a layout that has a sticky footer (using the cssstickyfooter.com method). inside my container div i have a content div that has four other divs inside of it. like so:

<div class="container">
    <div class="content">
        <div id="1"></div>
        <div id="2"></div>
        <div id="3"></div>
        <div id="4"></div>
    </div>
</div>
<div class="footer"></div>

In order for the sticky footer to work correctly all of the divs need to have position:relative; set, because the divs will have content that will be different lengths and they need to re-size accordingly. however where my dilemma begins is that i need to have divs 1-4 have position:absolute; set, so that they will stack on top of each other having the same (x,y) position.

is there any way to achieve what i need?


Solution

  • I typically just use the following to "stick" a div to the bottom of the page (or container):

    .footer {position:absolute;bottom:0;left:0;}
    

    Once you set position to absolute, it becomes independent of external divs and their position/dimensions.