Hi,
actually, all the browsers I’ve tested in just now (Firefox, Chrome and Opera) have the problem you describe.
It’s a tricky one. Here’s what’s happening:
Normally if you had just done this:
body{
background: #fff url(lightbluefade.jpg) 0 0 repeat-x;
}
it would have filled the screen. Not because the body is actually that big, but because of this rule in the specs:
For HTML documents, however, we recommend that authors specify the background for the BODY element rather than the HTML element. For documents whose root element is an HTML “HTML” element or an XHTML “html” element that has computed values of ‘transparent’ for ‘background-color’ and ‘none’ for ‘background-image’, user agents must instead use the computed value of the background properties from that element’s first HTML “BODY” element or XHTML “body” element child when painting backgrounds for the canvas, and must not paint a background for that child element. Such backgrounds must also be anchored at the same point as they would be if they were painted only for the root element.
Meaning, if you leave your background-position to 0 0 (or don’t mention it at all, which defaults to 0 0), your image actually gets placed on the HTML element itself, and the HTML element is always the full screen.
The body is not always the full screen. Like other boxes, it’s as tall as the content inside makes it (height: auto).
Because you want the image to start at the bottom of the body, you used
0 100% or left bottom
and I don’t know why, but apparently setting this means the image doesn’t get painted on the HTML element, but stays on the body… and the body isn’t tall enough (you have it completely empty right now).
You can do one of three things:
You could give the body a min-height of 852px. But this will cause a scrollbar for any pages whose content isn’t that tall, as you’ve said, so I guess you don’t want that.
Another option is to write your colours differently: let the image start at the top of the body, and set the background colour to the blue (#9cf). However, this means your body background is always blue and contrast issues may crop up esp if the image doesn’t render for some reason.
Last, if you really need to use an image this large and really have pages not all at least 852px tall and don’t want a scrollbar then this may be the one case where you need to put the image on the html element. Normally, you wouldn’t.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Background tile</title>
<style>
html {
height: 100%;
background: #fff url(lightbluefade.jpg) 0 100% repeat-x;
}
body {
padding: 0;
background-color: #fff;
}
</style>
</head>
<body>
<p>Hi</p>
</body>
</html>
The background-color: #fff on the body is just to show you where the body actually is.
On my computer, the above code looks like all blue, because my viewport isn’t as tall as that image. If I fullscreen it, it’s definitely blue at the bottom and goes to white as I near the top.
So this might still cause contrast issues. All your smaller pages will be blue, and all your longer pages will start out white. Might be confusing.