Code _javascript tips to allow IE to support RGBA background color

Source: Internet
Author: User
Code on:
<! DOCTYPE html> <ptml> <pead> <title>Demo</title> <style type= "Text/css" > #div1 {Pad ding:10px; width:380px; height:205px; Background:url (/upload/201007/20100713220102894.jpg); } #div2 {color: #FFF; font-size:40px; Font-weight:bold; Text-align:center; height:205px; line-height:205px; Background:rgba (125, 0, 0,. 3); Filter:progid:DXImageTransform.Microsoft.gradient (startcolorstr= #4B7D0000, endcolorstr= #4B7D0000); } </style> </pead> <body> <div id= "Div1" > <div id= "div2" > Hello world! </div> </div> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

The STARTCOLORSTR parameter value in the DXImageTransform.Microsoft.gradient filter is #aarrggbb, where AA is the hexadecimal representation of opacity, 00 is fully transparent, and FF is completely opaque, The decimal range is 0~255, and the remaining rrggbb is the hexadecimal code for the color. Examples of Background:rgba (125, 0, 0,. 3) indicate a red background of 30% opacity. How to convert 30% of the opacity into a 16 system? Very simple, first calculate the #aa decimal x,x/255 = 3/10, the solution X=3*255/10, and then convert X to 16, approximately equal to 4 B.

Attached below are the pictures used in the example:

Author: Zhou Mingzhi
The article is part of the content from: RGBa Browser Support

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.