How can one create an overlay in css?

前端 未结 9 2056
青春惊慌失措
青春惊慌失措 2020-11-29 17:58

I\'d like to create a div with an arbitrary size, then display something on top of that div. What is the best way to position and size the overlay exactly as the div below i

9条回答
  •  不知归路
    2020-11-29 18:43

             div{
             background-image:url('');
             background-size:cover;
             background-position:top center;
             position:relative;
             }
    
             div:before{
             content:'';
             position:absolute;
             left:0;
             top:0;
             height:100%;
             width:100%;
             background-color:rgba(0,0,0,0.7);
             }
    

提交回复
热议问题