Submitted about 1 year ago
Interactive-rating-components challenge HTML CSS JS
@NataliaDeJager
Design comparison
SolutionDesign
Solution retrospective
Hey there! Here's my solution to the challenge c:
Is there a way to write the background-color in css that is written with HSLA, using the :root variables but also adding the given opacity to that color?
Any help/feedback is appreciated!
Community feedback
- @teempePosted about 1 year ago
Hi :) I do not think you could change alpha for once defined color. You can manipulate with custom values of opacity, but you need to define your variables as values passed to hsl() function. See example below.
:root { --bg-color: 0, 0%, 0%; --opacity: 50%; } div { background-color: hsla(var(--bg-color), var(--opacity)); }
Hope it helps... a bit at least ;)
Marked as helpful0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord