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:
1. opacity {
2 filter: alpha (opacity = 50);/* IE */
3-moz-opacity: 0.5;/* earlier Mozilla */
4-khtml-opacity: 0.5;/* old Safari */
5 opacity: 0.5;/* supports opacity browsers */
6}
Use javascript to set an element to translucent:
1. object. filter = "alpha (opacity =" + opacity + ")";/** // * IE */
2. object. opacity = (opacity/100);/** // * Old Mozilla */
3object. KhtmlOpacity = (opacity/100);/** // * old Safari */
4object. opacity = (opacity/100);/** // * browser supporting opacity */
5
The effect is as follows:
Go to: http://www.cnblogs.com/netwenchao/archive/2009/07/16/1525077.html