error setting transparency in CSS file
I am trying to set the transparency of a table background color. But when I write this code in CSS it shows me the error "Validation (CSS2.1):开发者_如何学JAVA filter is not a known property name" and the same error for opacity.
Why is this so?
.semiTransparent
{
filter: alpha(opacity = 50);
opacity: 0.5;
}
The CSS Validator validates your style sheet against some profile, e.g. CSS Level 1 or CSS Level 2. Some browser Vendors however extend these profiles by new properties like Microsoft did with the scrollbar-base-color or filter property or Mozilla with the -moz-opacity property. The Validator is not aware of these properties and using them makes your style sheet invalid in terms of the CSS specifications. Either get rid of those properties or live with the fact, that your style sheets don't validate. You cannot have both.
http://www.websitedev.de/css/validator-faq :-)
Css filter is IE-specific. If you don't use color: rgba(r,g,b,a); where a is alpha channel responsible for transparency, you must use a few improper css properties to have semi-transparent object in all browsers.
.semiTransparent {
filter:alpha(opacity=50);
-moz-opacity:0.5;
-khtml-opacity: 0.5;
opacity: 0.5;
}
Above code works in all browsers, but is invalid.
filter is technically not a standard compliant property, it only works for IE. The opacity should be 0.5 not .5. Minor changes.
精彩评论