Compatible with CSS Transparent Code of mainstream browsers and mainstream css

Source: Internet
Author: User

Compatible with CSS Transparent Code of mainstream browsers and mainstream css

Transparency often produces good web page visual effects. The following is the CSS Transparent Code compatible with mainstream browsers.
Transparent_class {

Filter: alpha (opacity = 50 );

-Moz-opacity: 0.5;

-Khtml-opacity: 0.5;

Opacity: 0.5;

}

Filter: alpha (opacity = 50): This is set for IE6. The value ranges from 0 to 100, and the other three are 0 to 1.
-Moz-opacity: 0.5; To support earlier Mozilla browsers.
-Khtml-opacity: 0.5; to support some older versions of Safari browsers.
Opacity: 0.5; this is the most important because it is the CSS standard. This attribute supports firefox, Safari, and Opera.


CSS transparency inheritance
For example


However, the transparency attribute of CSS involves an inheritance problem. When transparency is set for the parent element, the child element automatically inherits its transparency.
Even if you specify a transparency of 1 for the child element, it is invalid.

If the child element is text
Three solutions.
1. If you can, you can ignore it for the moment.
2. Specify a relatively deeper color for the text book element. That is to say, when the child element inherits transparency, the text color is exactly what you want.
The premise is that the color may be deepened, and the color and transparency values need to be calculated in detail.
3. Set each layer for the transparency effect and text separately, that is, create a layer for the transparency. Then the text layer is covered.
Let's look at the code.

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.