From SASS docs:
You can also use interpolation in a calculation. However, if you do, nothing in the parentheses that surround that interpolation will be simplified or type-checked, so it’s easy to end up with extra verbose or even invalid CSS. Rather than writing calc(10px + #{$var}), just write calc(10px + $var)!
But when I try to compile that
$var: 10px;
span {
top: calc(10px + $var); // without interpretation
bottom: calc(10px + #{$var}); // with interpretation
}
I get this:
span {
top: calc(10px + $var); // obviously wrong
bottom: calc(10px + 10px);
}
If I understand docs correctly, top
should have assigned value 20px
. Without interpretation, calc
should be called as internal SASS function and return value. Why it didn't happen? How do I calculate without interpretation?