Compatible with IE8 Rgba () usage

Source: Internet
Author: User

Today, you have a problem with setting up a translucent white div in a page. This doesn't seem to be a problem, just set the following properties for this div:

RGBA (255,255,255,.1);

But be compatible to IE8. This is a bit of a sore egg. Because IE8 does not support the RGBA () function. Let's summarize the meaning of the RGBA () function.

The meaning of Rgba, R for Red,g on behalf of GREEN,B on behalf of blue, red and green Blue is the three primary colors. All colors can be made up of these three colors. A represents transparency. For example, Rgba (255,255,255,0.1) is white with a transparency of 0.1. In modern browsers, RGBA is supported. However, in IE8 and other antique-level browsers are not supported by RGBA, IE8 can only reluctantly support the RGB () function (that is, remove the transparency, can only represent color).

So setting up translucency in IE8 is going to cost a bit of brains. Learned from the great God can use the IE filter to solve this problem, the CSS code is as follows:

<style="White-space:pre" ></span>background:rgba (255,255,255,.1); filter:progid :D XImageTransform.Microsoft.gradient (startcolorstr= #19ffffff, endcolorstr= #19ffffff);   

The second sentence means to execute when the transparency of the previous line does not work. The meaning of this sentence is used to make the gradient. But this place doesn't need gradients. So two colors are set to the same color.

It is noted that the color "#19ffffff" is made up of two parts.

The first part is the number after the # . is the Iefilter value of the RGBA transparency 0.1. From 0.1 to 0.9 each number corresponds to a iefilter value. The corresponding relationship is as follows:

the second part is six bits after 19 . This is the color value of the six binary. Is the same as the value in the RGB function. For example, RGB (255,255,255) corresponds to #ffffff, all white.

Here, the use of RGBA can be 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.