HEX color equivalent to RGBa for transparency

For a given hex color code, how can I convert it to rbga color code, where a = 0.97, and the displayed color matches the original hex color?

In other words, if I have #ccc , I need the rgba equivalent, which still displays the same color as #ccc but has transparency.

+4
source share
1 answer

To convert to rgba you have to do this:

1- Divide your six-color code into 3 parts

 cccccc => cc(r)|cc(g)|cc(b) 

2- For each part, convert it to int using parseInt

 r = parseInt("cc", 16) g = parseInt("cc", 16) b = parseInt("cc", 16) 

3- Add the desired alpha value to your final rgba code

0
source

All Articles