Tim Streater said:
I have a page with the body background-color set to non-white. The last
div on the page is used as a footer, and I've set its background to
white.
Now, if the page as a whole has insufficient material in it to fill the
browser window, then that part of the window below the final div takes
the colour of the body's background-color.
How can I control the colour of that portion of the browser window (I'd
like it to be white)?
First suggestion is to be happy to set the background of the
footer to the same as the background to the viewport (set by html
or body bg) and to choose a nice contrasting color for the text.
Of course, everything depends on your design as a whole, but
generally, without knowing specifics, this looks better too. A
footer is something that is *apart* from all else and leaving it
on the viewport at the bottom with a nice readable color lends
itself to this separateness.
However, if something about your design makes it better for the
main content area or non-footer area to be white backgrounded I
can imagine that it is because you want something from above (for
example, a main content wrapper, with white background) to extend
further than it does and to *meet* the footer in a vertical sort
of way. And maybe your footer is a sticky one that keeps to the
bottom?
Or the footer to be just under but married in appearance by
background to the content. The latter should not be difficult,
the footer can safely be given a small height or padding. This
might solve your problem with little effort, but the footer
begins where the non-footer ends in this case. This is almost
always fine imo and much less trouble than trying to force
footers to the bottom of viewports.
Normally a div will have as much height as its content dictates
but you can change this behaviour by giving a height. Often a
specific heigh in px or ems is not what is wanted but you can
give it a percentage height. Everything depends, and with no url,
I merely remark that if the wrapper somehow goes from the top and
you want it to go to the or nearly the bottom, regardless of
viewport, you can give 100% height (remembering to tell the
browser what it is a percentage of (you need to set html and body
too).