Compatible with IE8 rgba () Usage

Source: Internet
Author: User

I encountered a problem today. I want to set a translucent white Div on a page. This does not seem to be a problem. You only need to set the following attributes for this Div:

background: rgba(255,255,255,.1);

But it must be compatible with IE8. This is a little painful. IE8 does not support the rgba () function. Next we will summarize the meaning of the rgba () function.

The meaning of rgba. R represents red, g Represents green, B Represents blue, and red, green and blue represent three primary colors. All colors can be combined by these three colors. A Indicates transparency. For example, rgba (255,255,255, 0.1) is white with a transparency of 0.1. Supports rgba in modern browsers. However, IE8 and other antique Browsers Do not support rgba. IE8 can only barely support the RGB () function (that is, with transparency removed, it can only represent colors ).

Therefore, in IE8, it will be costly to set translucent. The CSS code is as follows:

<span style="white-space:pre"></span>background: rgba(255,255,255,.1);        filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#19ffffff,endColorstr=#19ffffff);
The second sentence means that the statement is executed when the transparency of a row does not work. The meaning of this sentence is originally used for gradient. However, no gradient is required in this area. So both colors are set to the same color.

Note that the color "# 19ffffff" is composed of two parts..

The first part is #19. Is the iefilter value of rgba transparency 0.1. Each number from 0.1 to 0.9 corresponds to an iefilter value. The relationship is as follows:


The second part is the six digits after the 19th digit.. This is a hexadecimal color value. The value must be the same as that in the RGB function. For example, the # ffffff; corresponding to RGB (255,255,255) is white.

By now, rgba is compatible with IE8.

Compatible with IE8 rgba () Usage

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.