How can one create an overlay in css?

前端 未结 9 2050
青春惊慌失措
青春惊慌失措 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:28

    I'm late to the party, but if you want to do this to an arbitrary element using only CSS, without messing around with positioning, overlay divs etc., you can use an inset box shadow:

    box-shadow: inset 0px 0px 0 2000px rgba(0,0,0,0.5);
    

    This will work on any element smaller than 4000 pixels long or wide.

    example: http://jsfiddle.net/jTwPc/

提交回复
热议问题