Modifying the alpha channel of a color using CSS
Suppose you have a color defined in a CSS variable (e.g., var(--brand)
), and you want a more transparent version of it (for example, 75% opacity). You can achieve this using the color-mix()
function in CSS:
background: color-mix(in srgb, var(--brand) 75%, transparent);
Equivalent in SCSS, Less, and Stylus
SCSS:
color: rgba($brand, 75%);
Less:
color: rgba(@brand, 75%);
Stylus:
color rgba(brand, 75%)