Created
March 30, 2016 14:44
-
-
Save fotan/bc5a5d3219c4ab39dd65c99163266ecb to your computer and use it in GitHub Desktop.
SCSS - Background Gradient Mixin
This file contains 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
/// Background gradient helper | |
/// @access public | |
/// @param {Color} $start-color - Start color | |
/// @param {Color} $end-color - End color | |
/// @param {String} $orientation - Type of gradient, either `vertical`, `horizontal` or `radial` | |
/// @example scss - Usage | |
/// .foo { | |
/// @include background-gradient(red, black, 'vertical'); | |
/// } | |
/// @example css - Result | |
/// .foo { | |
/// background: -webkit-linear-gradient(top, red, black); | |
/// background: linear-gradient(to bottom, red, black); | |
/// } | |
@mixin background-gradient($start-color, $end-color, $orientation) { | |
background: $start-color; | |
@if $orientation == 'vertical' { | |
background: -webkit-linear-gradient(top, $start-color, $end-color); | |
background: linear-gradient(to bottom, $start-color, $end-color); | |
} @else if $orientation == 'horizontal' { | |
background: -webkit-linear-gradient(left, $start-color, $end-color); | |
background: linear-gradient(to right, $start-color, $end-color); | |
} @else { | |
background: -webkit-radial-gradient(center, ellipse cover, $start-color, $end-color); | |
background: radial-gradient(ellipse at center, $start-color, $end-color); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment