Skip to content

Instantly share code, notes, and snippets.

@zeroeth
Last active February 23, 2016 18:58
Show Gist options
  • Select an option

  • Save zeroeth/94e87a4a5adff3ed595a to your computer and use it in GitHub Desktop.

Select an option

Save zeroeth/94e87a4a5adff3ed595a to your computer and use it in GitHub Desktop.
360 degrees of CSS child selection
/* Try it out at http://lesscss.org/less-preview/ */
/* ~"" unquotes the strings in less. */
/* Im sure you could remove the double first arguments of "*" "*" but thats a task for another day */
/* Loop structure from http://meri-stuff.blogspot.com.br/2013/03/less-css-tips-and-trics.html */
/* looping mixin */
.loop (@index, @token, @selector, @joiner) when (@index > 0) {
/* do whatever you need to do */
@{selector} {
border: 2px solid hsl(@index, 100%, 50%);
}
/* loop */
.loop((@index - 1), @token, ~"@{selector} @{token}", @joiner);
}
/* stop mixin */
.loop (@index) when (@index <= 0) {
loop: end;
}
/* use looping mixin */
.loop(360, ~"*", ~"*", " ");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment