Created
April 17, 2013 06:30
-
-
Save mucsher/5402201 to your computer and use it in GitHub Desktop.
Loop in Less
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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