Search code examples
csssticky-footer

CSS Sticky Footer Failure


I am trying to get a Sticky Footer to work, and have currently tried the following css:

 #footer {
        width:920px;
        height:208px;
        font-size:10px;
        margin-left:auto;
        margin-right:auto;
        background-image:url(images/grad.png);
        background-repeat:repeat-y;
        padding:0 20px;
        clear:both;
        position:relative;
        margin-top:-208px;
 }

 body {
        margin:0;
        font-family:Arial, Helvetica, sans-serif;
        font-size:13px;
        color:#333333;
        background-repeat:repeat-x;
        padding: 0;
        height: 100%;
 }

 #wrap {
        width:960px;
        margin:0 auto;
        min-height:100%;
        height: 100%;
 }


    #content {
        width:892px;
        float:left;
        border-left:4px solid white;
        border-right:4px solid white;
        padding:15px 0px 15px 20px;
        background-image:url(images/sidebar_bg.png);
        position:relative;
        padding-bottom:143px;
    }

I have had to reduce the #content padding-bottom, so it would fit. But I am still having issues. Firstly, There is too much space at the bottom of longer pages (see - http://bellbird.redgraphic.co.uk/headteacher/ ) Secondly, on a shorter page the footer doesnt scroll up when the browser window is resized (see - http://bellbird.redgraphic.co.uk/school-council/ )

Sticky footers always seem to be an issue, so I must be missing a trick.

Any help would be greatly appreciated.

Lewis


Solution

  • usefull link here. This one helped me with the same issue.

    CSS mark-up:

    html,
    body {
       margin:0;
       padding:0;
       height:100%;
    }
    #container {
       min-height:100%;
       position:relative;
    }
    #header {
       background:#ff0;
       padding:10px;
    }
    #body {
       padding:10px;
       padding-bottom:60px;   /* Height of the footer */
    }
    #footer {
       position:absolute;
       bottom:0;
       width:100%;
       height:60px;   /* Height of the footer */
       background:#6cf;
    }
    

    HTML mark-up:

    <div id="container">
       <div id="header"></div>
       <div id="body"></div>
       <div id="footer"></div>
    </div>