在CSS中分层图像 - 可以将2个图像放在同一个元素中? [英] Layering images in CSS - possible to put 2 images in same element?

查看:118
本文介绍了在CSS中分层图像 - 可以将2个图像放在同一个元素中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在CSS中设置网页的背景图片,如下所示:

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;
}

有没有办法在桌面上叠加第二张图片。在body元素本身内,还是创建一个单独的类并使用z轴的唯一方法?

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?

谢谢!

推荐答案

简而言之,这是不可能的。您可以这样做,但是您需要向页面添加第二个HTML对象才能使其工作。例如,在您的身体正下方放置一个div块,并为该对象指定第二个背景。

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.

希望这会有所帮助!

这篇关于在CSS中分层图像 - 可以将2个图像放在同一个元素中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆