Skip to content

Instantly share code, notes, and snippets.

@karlbright
Last active December 11, 2015 23:58
Show Gist options
  • Save karlbright/4680211 to your computer and use it in GitHub Desktop.
Save karlbright/4680211 to your computer and use it in GitHub Desktop.
@function rainbow($position, $colors) {
$colors: if(type-of($colors) != 'list', compact($colors), $colors);
$gradient: compact();
$width: 100% / length($colors);
@for $i from 1 through length($colors) {
$pop: nth($colors,$i);
$new: $pop ($width * ($i - 1)), $pop ($width * $i);
$gradient: join($gradient, $new, comma);
}
@return linear-gradient($position, $gradient);
}
$mycolors: red orange yellow green blue indigo violet;
.rainbow {
@include background-image(rainbow(left, $colors));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment