Skip to content

Instantly share code, notes, and snippets.

@jackie
Created September 29, 2013 02:14
Show Gist options
  • Save jackie/6748736 to your computer and use it in GitHub Desktop.
Save jackie/6748736 to your computer and use it in GitHub Desktop.
Recursively generates a striped gradient.
$colors: #b00b00 #bada55 #de1e7e #f0feaf #ac1d1c #e1e100 #facade;
$stops: ();
@function gradient($i: 0) {
@if $i == length($colors) {
@return $stops;
}
$i: $i + 1;
$new-stops: nth($colors, $i) percentage(($i - 1)/length($colors)), nth($colors, $i) percentage($i/length($colors));
$stops: join( $stops, $new-stops, comma );
@return gradient($i);
}
$stops: gradient();
html {
@include background-image(linear-gradient( top center, $stops ));
height: 100px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment