Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Results Summary Component

@ImFropZ

Desktop design screenshot for the Results summary component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


How do you change from a variable that has HSL color as a value to HSLA color in CSS?

:root {
  --clr-red: hsl(0, 100%, 50%);
}

main {
  background-color: hsla(var(--clr-red), 0.5); -- not work
}

Community feedback

@rashidshamloo

Posted

There is no native function to do that in CSS. but in SASS/SCSS you can use the "rgba" function to add alpha to a color variable:

$clr-red: hsl(0, 100%, 50%);

main {
  background-color: rgba($clr-red, 0.5);
}

To see a list of other SASS color functions click here

Marked as helpful

1
PARKO001 190

@PARKO001

Posted

background-color: hsla(0, 100%, 50%, 0.5); --->this will work

[ 1. you have to add "a" at the end of "hsl" to make it "hsla". 2. add comma(,) and 0.5 inside the main hsl bracket at the extreme right]

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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