i have loop generates number 0-5, generate 20, in multiples of 5.
desired results be:
0, 1, 2, 3, 4, 5, 10, 15, 20
is possible in single @for statement?
@for $i 0 through 20 { @if $i < 5 , $i > 0 { .number-#{$i} { height:(#{$i}px); } } @if $i % 5 == 0 { .number-#{$i} { height:(#{$i}px); } } }
the output
.number-0 { height: 0px; } .number-1 { height: 1px; } .number-2 { height: 2px; } .number-3 { height: 3px; } .number-4 { height: 4px; } .number-5 { height: 5px; } .number-10 { height: 10px; } .number-15 { height: 15px; } .number-20 { height: 20px; }
the loop go through 0 20. check 1-5 through first if statement, using modulus i check divisible 5.
Comments
Post a Comment