Skip to content

Instantly share code, notes, and snippets.

@calvinjuarez
Last active December 21, 2015 03:48
Show Gist options
  • Save calvinjuarez/6244586 to your computer and use it in GitHub Desktop.
Save calvinjuarez/6244586 to your computer and use it in GitHub Desktop.
Basic LESS loop to generate as many numbered classes as necessary, extended to keep the CSS DRYer.
.example-1,
.example-2,
.example-3,
.example-4,
.example-5 {
/* stuff */
}
.example-1 {
/* stuff */
}
.example {
// Loop
.loop(@index) when (@index > 1) {
.loop((@index - 1));
&-@{index} {
&:extend(.example-1);
}
}
.loop(@index) when (@index =< 1) {}
// Generate
.loop(5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment