How to compile $i to "3 digits"?
@for $i from 1 through 100 {
.bg-image#{$i} {
background-image: url("folder/bg-image#{$i}.jpg");
}
}
I want it to compile like this.
.bg-image001 {
background-image: url("folder/bg-image001.jpg");
}
.bg-image002 {
background-image: url("folder/bg-image002.jpg");
}
...
.bg-image099 {
background-image: url("folder/bg-image099.jpg");
}
.bg-image100 {
background-image: url("folder/bg-image100.jpg");
}
I tried this way: https://www.sassmeister.com/gist/7581995
so:
.bg-image#{" d" % $i}
But an error occurred in webstorm.
Are there any other good methods? thanks for your help.
https://www.sassmeister.com/gist/7581995 In this way, This is an issue with spacing during the build process.
This is how I solved it:
@function zerofill($i) { @return #{str-slice("000",0,3 - str-length(#{$i}))}+$i; } @for $i from 1 through 100 { $i: zerofill($i); #layer-#{$i} { background: url('../layers/layer-#{$i}.png'); } }