Menü schliessen
Created: December 11th 2024
Last updated: December 19th 2024
Categories: Common Web Development,  CSS,  IT Development
Author: Tim Fürer

CSS: How to use Colour Function to Change Colour Opacity

Tags:  CSS,  guide
Donation Section: Background
Monero Badge: QR-Code
Monero Badge: Logo Icon Donate with Monero Badge: Logo Text
82uymVXLkvVbB4c4JpTd1tYm1yj1cKPKR2wqmw3XF8YXKTmY7JrTriP4pVwp2EJYBnCFdXhLq4zfFA6ic7VAWCFX5wfQbCC

Using the new color() CSS function, you can modify a given colour (even from a CSS variable).

Color() is Baseline since May 2023.

Here's an example using color() to change a colour's (#a24a9d) opacity to 50%:

color(from #a24a9d srgb r g b / 50%)

As mentioned, you can also use CSS variables:

color(from var(--some-color) srgb r g b / 50%)