Skip to content

Instantly share code, notes, and snippets.

@mucsher
Created April 17, 2013 06:30
Show Gist options
  • Save mucsher/5402201 to your computer and use it in GitHub Desktop.
Save mucsher/5402201 to your computer and use it in GitHub Desktop.
Loop in Less
@iterations: 30;
// helper class, will never show up in resulting css
// will be called as long the index is above 0
.loopingClass (@index) when (@index > 0) {
// create the actual css selector, example will result in
// .myclass_30, .myclass_28, .... , .myclass_1
(~".myclass_@{index}") {
// your resulting css
my-property: -@index px;
}
// next iteration
.loopingClass(@index - 1);
}
// end the loop when index is 0
.loopingClass (0) {}
// "call" the loopingClass the first time with highest value
.loopingClass (@iterations);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment