CSS transparent implementation method (1/3)

Source: Internet
Author: User

I. Old opacity settings
The following code sets the transparency required for earlier versions of firefox and safari:

 

The code is as follows: Copy code
# Myelement {-khtml-opacity:. 5;-moz-opacity: 0.5 ;}


-The khtml-opacity setting is intended for the earlier version of the webkit rendering engine. This type of special attribute is outdated, unless you still need to be compatible with safari 1.x.
The second line uses the dedicated property-moz-opacity to be compatible with earlier versions of the mozilla rendering engine and trace back to netscape navigator. The-moz-opacity attribute is not required for firefox 0.9 and later versions. firefox 3.5 (currently using the gecko engine) does not support this attribute.

II. css transparency in firefox, safari, chrome, and opera
The following code is the simplest and most up-to-date css syntax for all browsers except ie:

 

The code is as follows: Copy code
# Myelement {opacity:. 7 ;}


The preceding syntax sets an element to 70% opaque (or 30% transparent ). Setting opacity: 1 will make the element opaque, and setting opacity: 0 will make the element completely invisible. You only need to remember that "opacity" is equivalent to "opacity" and it is easy to remember that the smaller the opacity value, the closer it is to transparency.
The opacity attribute can be precise to the last two decimal places, so the values ". 01" and ". 02" are actually different, although the visibility is hard to find. Generally, it can be accurate to one digit. The value can be ". 3" or ". 7 ".

III. css transparency in ie
Ie is still different from other browsers. At present, there are three different versions of ie which are widely used. Transparency settings are different, and sometimes additional css is required for control:

 

The code is as follows: Copy code
# Myelement {filter: alpha (opacity = 40 );}


The css above uses a dedicated filter property to set the transparency of the ie6-8. For ie6 and ie7, note that to make the transparent settings take effect, the element must be "laid out ". An element can be laid out by using css attributes, such as width and position. For details about Microsoft's proprietary haslayout attribute and how to trigger it, refer to the 111cn.net documentation.
The syntax for setting the css transparency of ie8 is as follows (note the version mentioned in the comment ):

 

 

Homepage 1 2 3 Last page

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.