我有一个页面主体的背景,这是一个我希望通过第一级div而不是第二级显示的图像
<body>
<div style='opacity:0.9;'><p>This is a wrapper that shows some of the background</p>
<div style='background-color:#fff;'><p>This is a child div that I want to be all white</p>
</div>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
显然,第二级div获得了.9的不透明度,还有一种方法可以覆盖它吗?
Roh*_*zad 29
嗨,你可以这样做
您可以定义父选择性
和你一样的孩子
恩.
CSS
.parent{
padding:20px;
background:rgba(112,81,246,0.3);
}
.child{
padding:20px;
background:rgba(112,81,246,0.6);
}
?
Run Code Online (Sandbox Code Playgroud)
HTML
<div class="parent">
<div class="child">Hello i m child</div>
</div>?
Run Code Online (Sandbox Code Playgroud)
现场演示http://jsfiddle.net/rohitazad/PC4sL/