Last active
January 25, 2017 22:41
-
-
Save tylerpaige/023b9de0c9e6635828054b1b108a1777 to your computer and use it in GitHub Desktop.
Sass function: Given a list of colors, generates an evenly spaced striped gradient
This file contains hidden or 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
| @function stripes($list) { | |
| $value : (); | |
| @for $i from 1 through length($list) { | |
| $color : nth($list, $i); | |
| $start : 100% / length($list) * ($i - 1); | |
| $end : 100% / length($list) * $i; | |
| $rampSegment : $color $start, $color $end; | |
| $value : append($value, $rampSegment, comma); | |
| } | |
| @return linear-gradient($value); | |
| } | |
| /* | |
| EXMAPLE: | |
| $colors : red, green, blue; | |
| section { | |
| background-image: stripes($colors); | |
| } | |
| OUTPUT: | |
| section { | |
| background-image: linear-gradient(red 0%, red 33.33333%, green 33.33333%, green 66.66667%, blue 66.66667%, blue 100%); | |
| } | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment