I have a small problem with my site that I can’t seem to fix. I would like my footer to always stick to the bottom of the screen, unless the content is long enough to push it down. I use a “push” div between the content and the footer parts of my page in order to accomplish that, however in some browsers/resolutions it leaves a gap between the two parts or the footer overlaps a part of the content.
How do I fix this?
This is the CSS (removed irrelevant parts and styles)
You have too many nested divs and are using unnecessary wrappers in a lot of cases so don’t add divs for no reason.
The header rollovers could easily be done in css so you don’t need the DW MM js at all and would save miles of code.
Try to use html semantically and for menus and loads of links uses a list structure. Bare anchors should rarely butt up to each other as that is an accessibility issue and should be separated by a semantic html element ( otherwise screen readers will read them as a sentence an not as separate links).
Thanks for the code, that does look a lot less complex. I implemented your code, and it seems to work fine for resolutions of 1024x768 and up, but on my 13" laptop, the feet of the picture and the bottom half of the boxes on the homepage are cut off in all browsers. It still doesn’t seem to “push” the footer down.
True. I’m just used to the easy way Dreamweaver provides to do this and it is so fast that I generally don’t mind using this built-in function. I should really be less lazy and hand-code it in CSS.
Also a very valid point… Never really looked at it that way.
Yeah, I based my earlier code on an example I found here. I’ve used it several times, and it never caused any problems before. I’ll be sure to use your method from the sticky thread in the future.
The image is over twice the height of the container and therefore any content that sticks out of the container will be ignored in all browsers except ie6 as it always expands an element to accommodate content.
Remove the height from the sidebar and while you are at it remove the height:100% from pagebody because you can;t use height:100% in that way (see faq on 100% height for more info).
Firstly the method you are using is unreliable and broken in IE7, IE8 and opera. Refer to the CSS faq (sticky thread) as the sticky footer method is documented fully there and is the only working method to satisy all browsers (and developed in this forum).
Secondly your footer is 272px high but you are only making room for 60px of it to show? Why is this?
The footer height, the negative margin and the height of the push div should match for this to work properly. In my method I don’t need a push div because the space is soaked up by other means.
The issue you are experiencing with different gaps is because good browsers don’t actually need the push div because the clear: both on the footer ensures it doesn’t overlap. IE6 and 7 though do need it.
Use the method in the CSS faq and avoid the issue altogether. (Or just give IE6 and 7 the height in the push div using conditional comments or specific hacks).
If you struggle implementing it then shout and we’ll take another look. You have to fix the height of the footer to match the negative margins etc as I mentioned before.
(I also notice that you have some nested anchors in the footer which is not allowed - or that you have just misplaced a couple of closing tags)