Is it possible to have a child element behind his parent element with z-index

前端 未结 5 1170
逝去的感伤
逝去的感伤 2020-12-10 03:54

I would like to know if it possible to have a child element behind his parent element with z-index.

I would like to use the parent div as transparent color layer on

5条回答
  •  不思量自难忘°
    2020-12-10 04:21

    You could just do it the other way and use the child as the overlay like this

    HTML

    Cras venenatis ornare tincidunt. Nam laoreet ante sed nibh pretium nec gravida turpis dapibus. Curabitur lobortis; lacus sit amet rutrum aliquet, est massa feugiat lectus, bibendum eleifend velit metus vitae dolor! Duis vulputate mi vitae quam fermentum pharetra.

    CSS

    #stuff{
        position:relative;
        }
    
    .overlay{
        width:100%;
        height:100%;
        position:absolute;
        top:0;
        left:0;
        background:#ACA;
        opacity:0.4;
        }
    

提交回复
热议问题