Forum Moderators: open
Thanks,
Mischa
<Sorry, no personal URLs. See TOS [webmasterworld.com]>
[edited by: tedster at 9:14 pm (utc) on May 16, 2004]
Apparently this is the only way to do it because opacity is inherited.
Yes you are right, opacity is inherited. But you could easily specify your <p> tags to be non-transparent like p {opacity: none; } or if you only want your p's inside a td to be non-transparent, something like td p {opacity: none;} should do it (Im talking about the style sheet here).
Be aware of that very few browsers support the opacity attribute, I think mozilla might be the only one at the moment.
I would advice you to use a .png image instead for better cross-browser compability, but there are still some browsers that doesnt support it (like the beloved IE5/win).
I hope this helps.
I was under the impression that opacity is supported by ie5, mozilla and one other (safari?) but all by different call tags. Here's what I have...
.trans {
filter: alpha(opacity=60);
-moz-opacity:0.6;
opacity: 0.6;
-khtml-opacity: 0.6;
}
So here's a follow up question... Now that I got it to work with the div, should I worry about trying to make it work another way like with this p thing? And if it is better to still try and switch, how exactly do you write that p code in the style sheet. Does it go into the .trans code above?
Thanks!
PS I changed my profile domain to go to the staging site so people can see it and get a better idea of what I'm talking about.
I believe opacity is supported by mozilla, and filter is supported by ie/win. I actually dont know about safari, but I would be happy to test.
<added>
I just found out that even safari supports it. But there is a catch:
Safari v1.1 added -khtml-opacity, and safari v1.2 changed the name to just opacity. So if you want opacity to work in safari v1.1 and up, you should add opacity: 0.6; to your class.
</added>
I have the css I'm using in the last message of mine which covers I guess both safari 1.1 and 1.0? Thanks!
[edited by: tedster at 8:00 pm (utc) on May 17, 2004]
Try this code instead of using the extra div:
.trans {
background: red; /* testing only */
filter: alpha(opacity=60);
-moz-opacity:0.6;
-khtml-opacity: 0.6; /*safari 1.1 */
opacity: 0.6; /* safari 1.2 */
}
.trans p {
filter: none;
-moz-opacity:none;
-khtml-opacity: none;
opacity: none;
}
<table>
<tr>
<td class="trans">
<p>This text should be non-transparent on a transparent background.</p>
</td>
</tr>
</table>
Thanks!
At the time I thought it would work like normal inheritance but it obviously doesn't.. and the posted solution (adding position relative to the text element) appears to only work in IE..
so maybe not all that helpful really :(
Suzy