December 2023
Intermediate to advanced
242 pages
5h 28m
English
| Recipe 6 | Adding Transparency to Hex Colors |
Suppose you want to add a semi-transparent overlay to some elements of your app. For example, you may have a prompt that asks the reader to log in before proceeding, and you may want to include a semi-transparent white color around the prompt to blur the remainder of the page.
If you use a normal hexadecimal color, the overlay will completely obscure the content underneath it. If you use the CSS opacity, it will set the opacity of the element as a whole, including its contents.
You need a solution that lets you add transparency to a hex color.
Write a function that accepts a hex value and a percentage as input parameters. The function should convert the percentage into a hex value and then ...
Read now
Unlock full access