I just applied a opacity to a #wrapper
div
with a solid color:
jQuery("#wrapper").css({ opacity: 0.5 })
This works开发者_Go百科 nicely, but I don't want their children div
s to inherit the opacity. How do I avoid this behavior without using PNG transparency hacks?
Opacity is always inherited by descendant elements. There are no way to avoid it, and it isn't due to jQuery, but the way opacity works.
Clone the element (and children) and get the offsets. Then in the original element, hide all the inner elements. Now set the opacity. With the cloned element, place it on top of the original element (using position and the offsets), but this time hide the background to the cloned element.
精彩评论