Can a child div have a higher opacity than parent with css?

前端 未结 2 1317
Happy的楠姐
Happy的楠姐 2021-01-03 21:05

I have a background on a page body that is an image which I want to show through the first level of divs but not the second


      
相关标签:
2条回答
  • 2021-01-03 21:34

    Any of these should get you started:

    Answer 1

    Answer 2

    0 讨论(0)
  • 2021-01-03 21:37

    Hi you can do as like this

    You can define parent opicity

    and child as like you

    ex.

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

    Live demo here http://jsfiddle.net/rohitazad/PC4sL/

    0 讨论(0)
提交回复
热议问题