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

前端 未结 2 1338
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: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

    Hello i m child

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

提交回复
热议问题