开发者

Transparent foreground

开发者 https://www.devze.com 2023-04-10 03:54 出处:网络
I would like to add a semi-transparent uniform layer as a foreground for a 开发者_JAVA技巧div element. What is the best way to do that?You could use this CSS...

I would like to add a semi-transparent uniform layer as a foreground for a 开发者_JAVA技巧div element. What is the best way to do that?


You could use this CSS...

div.parent {
   position: relative;
}

/* this div is a descendent of the div above */
div.child {
   position: absolute;
   top: 0;
   right: 0;
   bottom: 0;
   left: 0;
   opacity: .6;
   background: #fff;
} 

jsFiddle.

If you want mouse events to go through this cover, add pointer-events: none to the div.child.

You tagged it jQuery, so to add this child element via jQuery...

$('div.parent').append('<div class="child" />');
0

精彩评论

暂无评论...
验证码 换一张
取 消