【问题标题】:Can a child div have a higher opacity than parent with css?子 div 的不透明度是否可以高于具有 css 的父级?
【发布时间】:2012-04-17 19:15:48
【问题描述】:

我在页面主体上有一个背景,它是我想通过第一级 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 也获得了 0.9 的不透明度,有没有办法覆盖它?

【问题讨论】:

标签: css opacity


【解决方案1】:

其中任何一个都可以帮助您入门:

Answer 1

Answer 2

【讨论】:

    【解决方案2】:

    你好,你可以这样做

    您可以定义父 opicity

    和你一样的孩子

    例如。

    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>​
    

    现场演示http://jsfiddle.net/rohitazad/PC4sL/

    【讨论】:

      猜你喜欢
      • 2020-10-04
      • 2013-07-27
      • 1970-01-01
      • 2017-08-05
      • 2011-07-05
      • 2011-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多