|
| 1 | +// Gradients |
| 2 | +hex(num) |
| 3 | + return base-convert(round(num), 16) |
| 4 | + |
| 5 | +argb(color) |
| 6 | + return s('#%s%s%s%s', |
| 7 | + hex(alpha(color) * 255), |
| 8 | + hex(red(color)), |
| 9 | + hex(green(color)), |
| 10 | + hex(blue(color))) |
| 11 | + |
| 12 | +// Horizontal gradient, from left to right |
| 13 | +// |
| 14 | +// Creates two color stops, start and end, by specifying a color and position for each color stop. |
| 15 | +// Color stops are not available in IE9 and below. |
| 16 | +gradient-horizontal($start-color = #555, $end-color = #333, $start-percent = 0%, $end-percent = 100%) |
| 17 | + //background-image -webkit-linear-gradient(left, $start-color $start-percent, $end-color $end-percent) // Safari 5.1-6, Chrome 10+ |
| 18 | + //background-image -o-linear-gradient(left, $start-color $start-percent, $end-color $end-percent) // Opera 12 |
| 19 | + background-image linear-gradient(to right, $start-color $start-percent, $end-color $end-percent) // Standard, IE10, Firefox 16+, Opera 12.10+, Safari 7+, Chrome 26+ |
| 20 | + background-repeat repeat-x |
| 21 | + filter s("progid:DXImageTransform.Microsoft.gradient(startColorstr='%s', endColorstr='%s', GradientType=1)", argb($start-color), argb($end-color)) // IE9 and down |
| 22 | + |
| 23 | +// Vertical gradient, from top to bottom |
| 24 | +// |
| 25 | +// Creates two color stops, start and end, by specifying a color and position for each color stop. |
| 26 | +// Color stops are not available in IE9 and below. |
| 27 | +gradient-vertical($start-color = #555, $end-color = #333, $start-percent = 0%, $end-percent = 100%) |
| 28 | + //background-image -webkit-linear-gradient(top, $start-color $start-percent, $end-color $end-percent) // Safari 5.1-6, Chrome 10+ |
| 29 | + //background-image -o-linear-gradient(top, $start-color $start-percent, $end-color $end-percent) // Opera 12 |
| 30 | + background-image linear-gradient(to bottom, $start-color $start-percent, $end-color $end-percent) // Standard, IE10, Firefox 16+, Opera 12.10+, Safari 7+, Chrome 26+ |
| 31 | + background-repeat repeat-x |
| 32 | + filter s("progid:DXImageTransform.Microsoft.gradient(startColorstr='%s', endColorstr='%s', GradientType=0)", argb($start-color), argb($end-color)) // IE9 and down |
| 33 | + |
| 34 | +gradient-directional($start-color = #555, $end-color = #333, $deg = 45deg) |
| 35 | + background-repeat repeat-x |
| 36 | + // background-image -webkit-linear-gradient($deg, $start-color, $end-color) // Safari 5.1-6, Chrome 10+ |
| 37 | + // background-image -o-linear-gradient($deg, $start-color, $end-color) // Opera 12 |
| 38 | + background-image linear-gradient($deg, $start-color, $end-color) // Standard, IE10, Firefox 16+, Opera 12.10+, Safari 7+, Chrome 26+ |
| 39 | + |
| 40 | +gradient-horizontal-three-colors($start-color = #00b3ee, $mid-color = #7a43b6, $color-stop = 50%, $end-color = #c3325f) |
| 41 | + // background-image -webkit-linear-gradient(left, $start-color, $mid-color $color-stop, $end-color) |
| 42 | + // background-image -o-linear-gradient(left, $start-color, $mid-color $color-stop, $end-color) |
| 43 | + background-image linear-gradient(to right, $start-color, $mid-color $color-stop, $end-color) |
| 44 | + background-repeat no-repeat |
| 45 | + filter s("progid:DXImageTransform.Microsoft.gradient(startColorstr='%s', endColorstr='%s', GradientType=1)", argb($start-color), argb($end-color)) // IE9 and down, gets no $color-stop at all for proper fallback |
| 46 | + |
| 47 | +gradient-vertical-three-colors($start-color = #00b3ee, $mid-color = #7a43b6, $color-stop = 50% , $end-color = #c3325f) |
| 48 | + // background-image -webkit-linear-gradient($start-color, $mid-color $color-stop, $end-color) |
| 49 | + // background-image -o-linear-gradient($start-color, $mid-color $color-stop, $end-color) |
| 50 | + background-image linear-gradient($start-color, $mid-color $color-stop, $end-color) |
| 51 | + background-repeat no-repeat |
| 52 | + filter s("progid:DXImageTransform.Microsoft.gradient(startColorstr='%s', endColorstr='%s', GradientType=0)", argb($start-color), argb($end-color)) // IE9 and down, gets no $color-stop at all for proper fallback |
| 53 | + |
| 54 | +gradient-radial($inner-color = #555, $outer-color = #333) |
| 55 | + // background-image -webkit-radial-gradient(circle, $inner-color, $outer-color) |
| 56 | + background-image radial-gradient(circle, $inner-color, $outer-color) |
| 57 | + background-repeat no-repeat |
| 58 | + |
| 59 | +gradient-striped($color = rgba(255, 255, 255, .15), $angle = 45deg) |
| 60 | + // background-image -webkit-linear-gradient($angle, color 25%, transparent 25%, transparent 50%, color 50%, color 75%, transparent 75%, transparent) |
| 61 | + // background-image -o-linear-gradient($angle, color 25%, transparent 25%, transparent 50%, color 50%, color 75%, transparent 75%, transparent) |
| 62 | + background-image linear-gradient($angle, $color 25%, transparent 25%, transparent 50%, $color 50%, $color 75%, transparent 75%, transparent) |
0 commit comments