Reputation: 377
I would like to do the following using SASS:
width: #{$percent}%;
Where $percent
is a variable containing a number. If $percent
is equal to 50, the precompiled CSS would be:
width: 50%;
What syntax should I use?
Upvotes: 18
Views: 4553
Reputation: 393
If anyone is looking answer for SCSS below code will work perfectly, just use css calc.
$percent: 50
.foo{
width: calc(#{$percent} * 1%)
}
Upvotes: 2
Reputation: 23883
Multiply by 1%:
$percent: 50
.foo
width: $percent * 1%
Result:
.foo {
width: 50%;
}
Upvotes: 34