开发者

reset inherited opacity/filter:alpha to full transparency

开发者 https://www.devze.com 2023-03-11 15:20 出处:网络
I have a <div> with a black background conta开发者_StackOverflow社区ining a white <h1> element. My <div> has an opacity of .4 using the following css combined with IE\'s method.

I have a <div> with a black background conta开发者_StackOverflow社区ining a white <h1> element. My <div> has an opacity of .4 using the following css combined with IE's method.

opacity: .4;
filter:  alpha(opacity=40);

This makes my <div> and <h1> have 40% transparency, but I want the h1 to have full transparency (white). How can I accomplish this with equal browser support? Thanks in advance!

P.S. I would use background:rgba(0,0,0,.4); but that's not something IE supports.


This is not possible - opacity values smaller than 1 can't be overridden by children.

The h1 would have to be in a different container than the div, or you would have to use a transparent PNG with 40% opacity for the background (which again won't work in IE6 without workarounds).

0

精彩评论

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