Last active
October 7, 2019 02:24
-
-
Save anovsiradj/3de6c00e85480a2e8b4f4dd2db0887e6 to your computer and use it in GitHub Desktop.
LESS: Loop dynamic selector rule (CSS)
This file contains 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
.looper(@class, @property, @unit: px, @min: 0, @max: 10, @step: 1) { | |
.loop(@i) when (@i <= @max) { | |
@cls: e(replace(@class, '\*', @i, 'g')); | |
@{cls} { | |
@{property}: unit(@i, @unit); | |
} | |
.loop(@i + @step); | |
} | |
.loop(@min); | |
} | |
/* | |
Usage: | |
.looper('.w-*', width, px); ===> .w-0 {width: 0px} ... .w-10 {width: 10px} | |
.looper('.h-*,', height, %, 0, 100, 10); ===> .h-0 {height: 0%} ... .h-100 {height: 100%} | |
Only support single rule. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment