I am using CSS attrubutes :
filter: alpha(opacity=90);
opacity: .9;
to make the DIV transparent, but when I add another DIV inside this DIV it makes it transparent also.
I want to make the outer(background) DIV only transparent. How ?
(To do so, use Gimp , Paint.Net or any other image software that allows you to do that. Just create a new image, delete the background and put a semi-transparent color in it, then save it in png.)
The percentage of opacity is calculated as Opacity% = Opacity * 100 To set the opacity only to the background and not the text inside it. It can be set by using the RGBA color values instead of the opacity property because using the opacity property can make the text inside it fully transparent element.
There's no CSS property that you can use to change the opacity of only the background image. Unlike background colors, which allow you to adjust the alpha channel to control opacity, it simply doesn't exist for the background-image property.
Fiddle: http://jsfiddle.net/uenrX/1/
The opacity property of the outer DIV cannot be undone by the inner DIV. If you want to achieve transparency, use rgba
or hsla
:
Outer div:
background-color: rgba(255, 255, 255, 0.9); /* Color white with alpha 0.9*/
Inner div:
background-color: #FFF; /* Background white, to override the background propery*/
EDIT
Because you've added filter:alpha(opacity=90)
to your question, I assume that you also want a working solution for (older versions of) IE. This should work (-ms-
prefix for the newest versions of IE):
/*Padded for readability, you can write the following at one line:*/ filter: progid:DXImageTransform.Microsoft.Gradient( GradientType=1, startColorStr="#E6FFFFFF", endColorStr="#E6FFFFFF"); /*Similarly: */ filter: progid:DXImageTransform.Microsoft.Gradient( GradientType=1, startColorStr="#E6FFFFFF", endColorStr="#E6FFFFFF");
I've used the Gradient filter, starting with the same start-
and end-color
, so that the background doesn't show a gradient, but a flat colour. The colour format is in the ARGB hex format. I've written a JavaScript snippet to convert relative opacity values to absolute alpha-hex values:
var opacity = .9; var A_ofARGB = Math.round(opacity * 255).toString(16); if(A_ofARGB.length == 1) A_ofARGB = "0"+a_ofARGB; else if(!A_ofARGB.length) A_ofARGB = "00"; alert(A_ofARGB);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With