Trying to create some classes to define opacity with the following code:
$i : 0;
@while $i <= 1 {
.opacity-#{$i*100} {
opacity: $i !important;
}
$i : $i + 0.1;
}
But I get the following error:
Invalid CSS after ".opacity-30.": expected class name, was "0"
Looks like it's adding a period after while... not sure what might be causing this.
Using Sass 3.4.14
Using Compass
Any ideas?
Thanks!
It seems you need to round the number in the class name: if you print
/* #{$i*100} */
the compiler will compute both30.0
,90.0
and100.0
So you may use
round()
function (reference) to get rid of any decimalsThe resulting output (tested on sassmeister) is