2

consider this problem... two .scss sheets

*styles.scss*
@import _variables.scss

--app-color: rgb(0,0,0); //css variable

*_variables.scss*

$color: var(--app-color); //CSS to SASS variable

now we can everywhere use $color variable filled with CSS variable color and it works.

My problem is using this SASS/CSS variable to set opacity. Look at this =>

background: rgba($color, .1);

it will NOT work... because $color in this case will not be passed like common color value like I defined (

rgb(0,0,0)

) but like (

var(--app-color)

and function rgba() probably don't know how to handle this parameter.

rgba() can handle two parameters ($color, $alpha) which works perfectly, but not if $color/$alpha are filled with CSS variables values )

... any idea how to solve this? Am I wrong with how I understand it ?

Thank you

0

1 Answer 1

2

I think you are mistaking the css functional notation for color and the sass rgba() function they may have a similar syntax but they are totally different functions. The first one requires three parameters and the second one will work only when its two parameters are passed before compilation and therefore cannot work with css variables which can change at any time.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.