CSS Opacity multi-browser transparency compatibility processing, cssopacity
The Opacity used to set the transparency of elements is an attribute in CSS 3. Of course, only a few browsers are supported.
However, each browser has its own private attributes, including earlier versions of Mozilla and Safari:
IE: filter: alpha (opacity)
Mozilla:-moz-opacity
Safari:-khtml-opacity
Unfortunately, you didn't see Opera. in earlier versions, Opera has no private attribute to replace opacity. (The new version of Opera already supports opacity)
Therefore, if we used CSS to set an element to be translucent, we may write it like this:
. Opacity {
Filter: alpha (opacity = 50);/* IE */
-Moz-opacity: 0.5;/* earlier Mozilla */
-Khtml-opacity: 0.5;/* old Safari */
Opacity: 0.5;/* supports opacity browsers */
}
Use javascript to set an element to translucent:
Object. filter = "alpha (opacity =" + opacity + ")";/* IE */
Object. Required opacity = (opacity/100);/* earlier Mozilla */
Object. KhtmlOpacity = (opacity/100);/* old Safari */
Object. opacity = (opacity/100);/* supports the opacity browser */