Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用css时,子div的不透明度是否可以高于父div?_Css_Opacity - Fatal编程技术网

使用css时,子div的不透明度是否可以高于父div?

使用css时,子div的不透明度是否可以高于父div?,css,opacity,Css,Opacity,我在页面主体上有一个背景,这是我想通过第一级div显示的图像,但不是第二级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

我在页面主体上有一个背景,这是我想通过第一级div显示的图像,但不是第二级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>

这是一个显示一些背景的包装器

这是一个我想要全白的儿童版


很明显,第二级div也会选择.9的不透明度。有没有办法覆盖它?

以下任何一项都应该让您开始:


嗨,你可以这样做

您可以定义父城市

和你一样的孩子

css

.parent{
    padding:20px;
    background:rgba(112,81,246,0.3);
}
.child{
    padding:20px;
    background:rgba(112,81,246,0.6);
}
​
HTML

<div class="parent">
<div class="child">Hello i m child</div>
</div>​

你好,我是孩子
​

这里有现场演示

这应该会有所帮助。简单的答案是否定的:你需要找到解决方法。可能的重复