Search code examples
internet-explorercssrgba

RGBa in Internet Explorer


I know that IE does not support RGBa. I also know that you can use the follow methods:

/* For IE 5.5 - 7*/
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);
/* For IE 8*/
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)";

The first two Numbers in the "Colorstr" is the value for the opacity. with 99 being a .6 opacity. For other levels of opacity what are the number values? I cannot find them. Is there a simple way to calculate the number for opacity? Or where can I find those values?

Thanks =>


Solution

  • Looks like it's straight 1-byte hexadecimal, so just do this

    Say your opacity is 30%:

    .30 * 255 = 76.5
    76 -> hex = 4C
    

    You can convert decimal to hex using a variety of desktop tools, online pages, or this JS function:

    new Number(76).toString(16);