J0nny
03 Dec 2007, 03:26 PM
Hey there, this has been bugging me for quite a while. It's the sort of problem where I have a solution for either or, but not both. My new website has a footer, which is placed at the bottom of the content. I need the footer to be positioned at the very bottom of the user's screen IF the content isn't longer than the screen. If the content IS longer than the users screen, the footer should be at the bottom of the content.
If the content is shorter than the users screen, a simple
position: fixed;
bottom: 0px;
works just fine. However, as soon as the content becomes longer than the screen, the footer remains at the bottom of the browser, cutting off the content. To fix this, I have to do a
display: table;
vertical-align: bottom;
However, as soon as the page becomes shorter than the users screen again, it sits at the bottom of the content, not the bottom of the screen. I hope I've been clear, I'll admit it is a bit confusing.
I'm wondering if there is a CSS solution to this, so I don't have to rely on doing a nasty JavaScript hack to check the content height and users screen height. Don't worry about it working in IE/Netscape, I don't really care about that. Firefox and Opera are a must though :P
Regards, J0nny.
If the content is shorter than the users screen, a simple
position: fixed;
bottom: 0px;
works just fine. However, as soon as the content becomes longer than the screen, the footer remains at the bottom of the browser, cutting off the content. To fix this, I have to do a
display: table;
vertical-align: bottom;
However, as soon as the page becomes shorter than the users screen again, it sits at the bottom of the content, not the bottom of the screen. I hope I've been clear, I'll admit it is a bit confusing.
I'm wondering if there is a CSS solution to this, so I don't have to rely on doing a nasty JavaScript hack to check the content height and users screen height. Don't worry about it working in IE/Netscape, I don't really care about that. Firefox and Opera are a must though :P
Regards, J0nny.