I have a div tag contain text:
<div id="XXX" class="xxx">
fffsdssfdf
</div>
And the CSS like this:
.xxx{
opacity :50;
}
But the Text doesn't opacity.
I have a div tag contain text:
<div id="XXX" class="xxx">
fffsdssfdf
</div>
And the CSS like this:
.xxx{
opacity :50;
}
But the Text doesn't opacity.
It depends on your browser. Opacity works for Firefox and Safari. (use "opacity:" instead of "opacity :"). You also have to fix the opacity value, because this value must be defined between 0 and 1.
For IE, try :
filter: alpha(opacity=85)
Opacity is a CSS 3 propery. It's expressed from 0 - 1.0. So 50% opacity would be like this:
.xxx {
opacity: 0.5;
}
It's also not supported in many browsers (IE 6 & IE 7), but there are some workarounds. Examples here: http://webdesign.about.com/od/css3/a/aa121306.htm
For those browsers supporting RGBA:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
h1 {
color: rgba(255, 0, 0, .5/* opacity */);
}
</style>
</head>
<body>
<h1>RED</h1>
</body>
</html>
For cross browser opacity, you want:
{
-moz-opacity:.50;
filter:alpha(opacity=50);
opacity:.50;
}
Courtesy of http://davidwalsh.name/css-opacity
.show-50 {
-moz-opacity:.50;
filter:alpha(opacity=50);
opacity:.50;
}
Courtesy of Laith Bade
.show-50 {
-moz-opacity:.50;
-ms-filter:"alpha(opacity=50)";
filter:alpha(opacity=50);
opacity:.50;
}