Opacity multi-browser transparency compatibility Processing

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.