views:

4367

answers:

7

Supposing I'm setting a background image for a web page in CSS like this:

body    {
font-size: 62.5%; /* Resets 1em to 10px */
font-family: Verdana, Arial, Sans-Serif;
background-color: #9D5922;
color: #000;
margin-left: auto;
margin-right: auto;
margin: 0;
padding: 0; 
background: url(images/desk.gif) repeat bottom left;
}

Is there any way to layer a second image on top of the desk.gif within the body element itself, or is the only way to create a separate class and use the z axis?

Sorry, it's a simpleminded question, but I've been trying to figure this out and though I haven't been able to make it work, I also haven't found a clear slapdown of the idea anywhere online... so, is there a way, or is this just a no can do?

Thanks!

A: 

The only way is to use another container. Each element may contain only one background image.

Will Bickford
+1  A: 

Hi Bill,

In short, it's not possible. You can do this, but you need to add a second HTML object to the page to get it to work. So for example, place a div block right below your body, and assign the second background to that object.

Hope this helps!

-Dave

Dave
I figured, but it was a hope! Thanks, I'll do it with a div block.
Dave
Actually, in CSS3, via border images - see http://www.w3.org/TR/2002/WD-css3-border-20021107/ (AFAIK, only Safari and FF3.1 support this though)
Shog9
A: 

Use absolute positioning and a z-index to get the second element on top.

codeinthehole
A: 

Don't forget you can apply styles to the HTML element

html { background: url(images/whatever.gif); }

Andy Ford
+2  A: 

Layered backgrounds are part of the CSS3 Working Draft but, as far as I know, support for them is limited to WebKit/KHTML-based browsers such as Safari, Chrome, Konqueror and OmniWeb.

Using your example code, this would look like:

body    {
    font-size: 62.5%; /* Resets 1em to 10px */
    font-family: Verdana, Arial, Sans-Serif;
    background-color: #9D5922;
    color: #000;
    margin-left: auto;
    margin-right: auto;
    margin: 0;
    padding: 0; 
    background: url("images/top.gif") left bottom repeat,
                url("images/desk.gif") left bottom repeat;
}
scronide
+1  A: 

I've already posted the solution in a duplicate question, but for anyone that may require this information I'll post it here as well.

As far as I am aware it is not possible to put it in the same layer, but it is possible to put several images in separate div's on top of one another, and has been implemented by popular usability testing website Silverback (check the background to see how it has been layered). If you look through the source code you can see that the background is made up of several images, placed on top of one another.

Here is the article demonstrating how to do the effect can be found on Vitamin. A similar concept for wrapping these 'onion skin' layers can be found on A List Apart.

EnderMB
This is a much more useful answer than the "accepted" answer.
Nathan Bowers
A: 

link text

Above mentioned link best describes what you r upto...

booota