Skip to content

Instantly share code, notes, and snippets.

@juliozuppa
Forked from danro/loop.less
Created March 29, 2017 20:53
Show Gist options
  • Select an option

  • Save juliozuppa/1f933eb0fedd8e2cbd128bd09619de00 to your computer and use it in GitHub Desktop.

Select an option

Save juliozuppa/1f933eb0fedd8e2cbd128bd09619de00 to your computer and use it in GitHub Desktop.
LESS css loop example
.loop (0) {}
.loop (@index) when (@index > 0) {
.classname-@{index} {
top: @index * 1px;
}
.loop (@index - 1);
}
#example {
.loop(5);
}
#example .classname-5 {
top: 5px;
}
#example .classname-4 {
top: 4px;
}
#example .classname-3 {
top: 3px;
}
#example .classname-2 {
top: 2px;
}
#example .classname-1 {
top: 1px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment