Search code examples
htmlcsssticky-footer

CSS - Sticky Footer With Multiple Divs Inside Footer Not Working


I am trying to implement a sticky footer which has three divs stacked inside the footer div. Now if I load a page where I keep the content block empty, the footer is not sticky anymore :(. I was wondering what am I doing wrong?

CSS (Code Stripped to show only the relevant CSS):

/* Custom Sticky Footer */
 .wrap {
    min-height: 100%;
    height: auto !important;
    height: 100%;
    margin: 0 auto -553px; /* Should be -553 px, but somehow doesnot work. This is a hack */
}
.push,
.footer {
    height: 553px;
}

.footer{
    background-color: #fff;
}

#footer-margin-top{
    height: 20px;
}
#footer-top{
    background-color: #333333;
    height:402px;
}
#footer-bottom{
    background-color: #232323;
    height: 131px;
    border-top: 1px solid #444444;
}

And HTML (Code Stripped to show only the relevant divs):

<!DOCTYPE html>
<html lang="en">

    <head>


    </head>

    <body>
    <div class="wrap">
    <div class="container">
    </div>
    <div class="push"></div>
    </div>
    <div class="footer">
        <div id="footer-margin-top"></div>
        <div id="footer-top">
            <div class="row-fluid">
                <div class="span12 social">
                </div>
            </div>
        </div>
        <div id="footer-bottom"></div>
    </div>
</body>
</html>

JSFiddle


Solution

  • Just add

    html, body { height : 100% }
    

    see on cssdesk or jsfiddle