Created
February 18, 2016 18:51
-
-
Save coderfin/28ad04ecfed07afe6722 to your computer and use it in GitHub Desktop.
.less loop (recursive, array, extract, variable, escape, length, mixin)
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
// This is an example of how an array can be created and a recursive mixin used to generate complex css. | |
@platforms: "ios", "android", "windows", "amazon", "roku", "xbox", "xbox_one", "chrome"; | |
.loopPlatforms(@i) when (@i > 0) { | |
@name: extract(@platforms, @i); | |
@id: ~"#@{name}"; | |
a[href="@{id}"] { | |
background-image: url("/Content/images/apps/@{name}_off.png"); | |
} | |
&.ui-state-active a[href="@{id}"], a[href="@{id}"]:hover { | |
background-image: url("/Content/images/apps/@{name}_on.png"); | |
} | |
.loopPlatforms(@i - 1); | |
} | |
.loopPlatforms(length(@platforms)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment