CSS Opacity multi-browser transparency compatibility processing, cssopacity

Source: Internet
Author: User

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 */

 

Related Article

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.