HTML & CSS
I've got a problem that is probably pretty common but I'm not finding any good ways to solve it. I have a fixed height footer on a page and when I view it in a standard browser it looks fine (see left image below). However when I view the site on a mobile device in a vertical orientation (or a standard browser with a very high screen resolution) I see the background of the page below the footer (see right image below).
Are there any easy ways to set a minimum height of the footer div, and also have it expand vertically in situations where the viewable area is larger?
The solution I always use for that is to make the footer background color the background color of the <body> element. That's the super easy way. Anything else will be fiddly. If your content area relies on the current background color, then you'll have to wrap it in a containing div with the gray background color.
You may try the following option
border-left: 1px solid #98b4f0;
border-right: 1px solid #98b4f0;
<div class="header"> </div>
<div class="body_content"> </div>
<div class="footer"> </div>
Make sure your document type is something like:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
No you can't do that I'm afraid as that would mean that your element can never grow further than the bottom of the viewport and will just spill out. You should use min-height:100% instead. See the css faq on 100% height for a full explanation.
It looks like a sticky footer would be more appropriate here:
This topic is now closed. New replies are no longer allowed.