Position footer at bottom regardless of content height.
I've been trying for ages, and I cannot work out how to make a footer align at the bottom of a webpage regardless of how tall or small the content is.
My website looks the same in Internet Explorer 7, Firefox, Opera and Safari. All my pages pass validation over at w3.
At the moment each page has a different #footer style tag, this tag changes on each page, inside of the style is just 'top: ?px', this places the footer at the bottom. I've tried 'bottom: 0;' and it simply will not work, here's my code:
Maybe I'm not understanding you, because I'm not sure what the difference between a "page on show" and a "whole page" is. From what I understood of you initial post, you want the footer "pinned" to the bottom of the screen. What I gave you does this in my tests in FF3 and IE7.
Scott Prelewicz
Senior Web Developer
COMAND Solutions
Clearly I'm misunderstanding the requirement, as I thought he wanted the footer to be positioned at trhe bottom *regardless* of the normal flow. So, yes, we would need more info and a link would be great.
Scott Prelewicz
Senior Web Developer
COMAND Solutions
Clearly I'm misunderstanding the requirement, as I thought he wanted the footer to be positioned at trhe bottom *regardless* of the normal flow. So, yes, we would need more info and a link would be great.
On a shortpage like this the code you gave me is good, but on a long page like this the footer would be in middle of the content because it goes to the bottom of the window and not the height of the browser. I'm on a 1440x900 sized screen so bare that in mind when I say it's a short page.
Basically I want the footer to always be at the bottom if the page is 100px tall or 5000px tall.
You're going about this the wrong way. Each time you position an element absolutely, you're taking it out the document flow, as a result, none of your elements know the relation to each other.
Having said that, here's the approach you should take:
Float main_left and main_right to the left, remove absolute positioning. Then on your footer, get right of the positioning and give it a clear of both. That will give you a sticky footer.
When you float main_left and main_right, you are taking these out of the normal flow, but by giving footer a clear of both, you cause footer to reset to the normal flow of the document, giving it the height it needs to "clear" main_left and main_right.
Last edited by ryanbutler; 02-18-2009 at 03:04 PM.
Bookmarks