Skip to content

Instantly share code, notes, and snippets.

@simonsmith
Created July 6, 2012 14:04
Show Gist options
  • Save simonsmith/3060329 to your computer and use it in GitHub Desktop.
Save simonsmith/3060329 to your computer and use it in GitHub Desktop.
Nested loops in LESS
.outer(@outer) when (@outer > 0) {
(~".outer@{outer}") {
color: red;
.inner(@inner) when (@inner > 0) {
font-size: @inner;
.inner(@inner - 1);
}
.inner(0) {}
.inner(@outer);
}
.outer(@outer - 1);
}
.outer(0) {}
// Gives you
.outer3 {
color: red;
font-size: 3;
font-size: 2;
font-size: 1;
}
.outer2 {
color: red;
font-size: 2;
font-size: 1;
}
.outer1 {
color: red;
font-size: 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment