views:

804

answers:

7

Hi css experts

I'm having a problem with my site http://artygirl.co.uk/pixie/about/ I can't seem to get the footer to automatically stick to the bottom of the browser, and show the rest of my background. Is there a solution better than using position:fixed or absolute?

I think there are possibly other styles over-riding some tests I do in firebug.

Thanks for your help Regards Judi

+1  A: 

This is always a bit difficult, you could increase the min-height of your content area, but even then if someone has a really big screen you'd see the same thing.

You could use a bit of JavaScript to increase the min-height if someone has a huge viewport but that's still less than elegant. I'm not sure if there is a CSS-only solution to this.

If you want to try the above the code I just posted here: http://stackoverflow.com/questions/2571514/is-detecting-scrollbar-presence-with-jquery-still-difficult/2571591 may be of use to you.

Steve
Damn, you beat me to it!
Josh
Now I feel determined to come up with a CSS only solution ;-)
Josh
A: 

You could set a min-height on #content. This won't fix the footer to the bottom of the browser specifically, but will ensure that you can always see a certain amount of the background.

As an alternative, using JavaScript, you could determine the height of the browser window and then calculate the min-height for #content, and apply it using JavaScript. This would ensure the footer is always in the correct place.

Josh
+2  A: 

I've used the technique in this article before: CSS layout: 100% height with header and footer. It does require some extra markup in your HTML.

roryf
WOW thanks this sounds great. It won't weork on my theme though so I might try it on a different one :)
judi
That's pretty slick. I'm on my netbook so I can't test it in other browsers though- are there any it doesn't work in?.. IE6?
Steve
I've just implemented this solution on my new portfolio :)
Steve
A: 

I've figured it out. Html had a css property for the background saying the colour white.

judi
+1  A: 

Set the height of html and body to 100%, insert a container div with min-height 100% and relative position, and nest your footer with position: absolute, bottom: 0;

/* css */
html, body {
    height: 100%;
}

#container {
    min-height: 100%;
    position: relative;
}

#footer {
    position: absolute;
    bottom: 0;
}


<!-- html -->
<html>
<head></head>

<body>
  <div id="container">
    <div id="footer"></div>
  </div>
</body>
</html>
digitaldreamer
Identical to what Rory Fitzpatrick posted, minus IE6 compatibility and working demo.
Steve
A: 

I always prefer page wise footers because of variable content on pages. I use a top margin of 5em for my footers. Most often than not, we know the height of content that can occur on pages.

pokrate
A: 

this technique is good.

http://www.cssstickyfooter.com/using-sticky-footer-code.html

Buena suerte!

Oscar Sobrevilla