Answer the question
In order to leave comments, you need to log in
How to set variables in SCSS/SASS?
SCSS/SASS has the ability to read values as percentages.
For example:
font-size: 16px is the base font size for the body.
font-size: 60/16*100%; - title font in percent (375%)
In order not to write every time ( /16*100% ) I want to set a variable.
$a: /16*100% - immediately swears at a slash, remove it...
$a: 16*100%;
I want to substitute further:
font-size: 60/$a: 16*100%;
But I get:
Error: 0.0375/% isn't a valid CSS value.
This means: the order of multiplication is violated?, first the variable is considered separately, and then its value ( 1600 ) is substituted, how can I fix it.
Ps I've been playing with SCSS/SASS for the first day.
Answer the question
In order to leave comments, you need to log in
Well, you can't divide a number by percentages.
Do this:
Or better yet, write a separate function like:
$a: 60 / 16 * 100 + '%';
@function percent-font-size($base) {
@return $base / 16 * 100 + '%';
}
font-size: percent-font-size(16);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question