I recently saw a discussion on CSS-D about multiple background images, and while it doesn’t exactly answer the question I thought I’d share a tip that some of you may find useful. At least until multiple backgrounds with CSS3 is properly supported.
So, what we want to do here is put a background image in each of the four corners of the body. The mark-up we need:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Example: A background image in each corner</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div id="outer_container">
<div id="container">
</div>
</div>
</body>
</html>
Unfortunately the extra DIVs are required as a hook for the background images, but we can reduce the number required down to two by using the HTML element and the BODY element as hooks for two of the images.
And the CSS:
* { margin: 0; padding: 0; }
html { background: #fff url(../images/top_left.gif) top left no-repeat; height: 100%; }
body { background: url(../images/top_right.gif) top right no-repeat; height: 100%; }
#outer_container { background: url(../images/bottom_left.gif) bottom left no-repeat; height: 100%; }
#container { background: url(../images/bottom_right.gif) bottom right no-repeat; min-height: 100%; _height: 100%; }
The only thing really to note is that _height: 100%; is a hack for IE6 to mimic the behaviour of min-height: 100%;, and will cause the stylesheet to fail validation. You can put that in an IE only stylesheet if that sort of thing bothers you.
Here is our working example. This technique has been tested to work in Firefox, Opera, Safari for Windows, IE7, and IE6.
Also, just as a note this technique can cause some freaky results when page-zoom is used in IE7, but to a lesser or greater extent this sort of thing will always choke a little in IE7 with page-zoom.