Html 如何将背景图像应用于低div
例如,html代码Html 如何将背景图像应用于低div,html,css,Html,Css,例如,html代码 <div id="container_background"> <div id="content"> <p> #container </p> </div> </div> 如果我这样编码,背景应用于#container#u background div,而不是#content div 我该如何申请内容 当然,内容内的背景图像将不是一个
<div id="container_background">
<div id="content">
<p>
#container
</p>
</div>
</div>
如果我这样编码,背景应用于#container#u background div,而不是#content div
我该如何申请内容
当然,内容内的背景图像将不是一个选项,因为图像必须是一个连接的图像,但如果我这样说,它将不会连接。使用css的跨浏览器透明度:
#content {
filter: alpha(opacity=0); /* internet explorer */
-khtml-opacity: 0; /* khtml, old safari */
-moz-opacity: 0; /* mozilla, netscape */
opacity: 0; /* fx, safari, opera */
}
您应该向div添加类,而不是像这样的标识符:
.container-background .content {
background:transparent;
}
试试这个CSS: 对于
#容器\u背景
:
#container_background{
background-image:url('main_bg.gif');
height: 430px;
}
对于#内容
:
#content{
background-color:transparent;
}
不理解。您的意思是#container#u background div的背景图像也将显示在#content div中吗?
#content{
background-color:transparent;
}