LCDesign Cambridge
LCDesign Cambridge

Reputation: 144

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

Upvotes: 0

Views: 684

Answers (3)

peterchon
peterchon

Reputation: 250

html:

<div class="wrap">
  <div class="inner-wrap">
  ...
  </div>
</div>
<footer>
...
</footer>

css:

html, body {height:100%;}
.wrap {min-height:100%; height:auto !important; margin-bottom:-100px;}
.inner-wrap {padding-bottom:100px;}
footer {height:100px;}

Upvotes: 0

DiederikEEn
DiederikEEn

Reputation: 743

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>

Upvotes: 2

The Mechanic
The Mechanic

Reputation: 2329

use this css instead of your

#footer {
   position:fixed;
   bottom:0;
   left:0;
   right:0;
   height:40px;   /* Height of the footer */
   background:#6cf;
}

Upvotes: 0

Related Questions