Answer the question
In order to leave comments, you need to log in
Why Use Loops in Sass?
I'm very interested in why Sass has these cycles and what their practical application is, if we still get just css at the output. What's the point of them?
Answer the question
In order to leave comments, you need to log in
Why do you need cycles? Say
var arr = [];
for(var i =0; i < 10; i++) {
arr.push(i);
}
var arr = [];
arr.push(0);
arr.push(1);
arr.push(2);
//...
arr.push(9);
Simplifies writing constructions of the form:
.class_1 {...}
.class_2 {...}
.class_3 {...}
.class_4 {...}
...
.class_N {...}
For example, yesterday users of my library (material design color palette for Less, Scss, Stylus) wanted to generate selectors for themselves and had to write a mixin to generate them. Nobody wants to write ~100 selectors manually. In the same way, for example, a grid is built in Bootstrap.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question