forked from drublic/Sass-Mixins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_linear-gradient.scss
46 lines (43 loc) · 1.75 KB
/
_linear-gradient.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* @description
* Generates a linear gradient for a given element with a fallback color.
*
* @author drublic
*
* @link caniuse
* @link spec
*
* @dependency helper-gradient-angle
* @param direction {'to bottom'|'to right'|'to top'|'to left'|<degree>}
* @param fallback {color}
* @param from {color}
* @param to {color}
* @default 'to bottom', #ccc, #ccc, #aaa
*
* @returns
* background-color: <fallback>;
* background-image: -webkit-gradient(linear, <direction - old converted>, from(<from>), to(<to>));
* background-image: -webkit-linear-gradient(<direction - converted>, <from>, <to>);
* background-image: -moz-linear-gradient(<direction - converted>, <from>, <to>);
* background-image: -o-linear-gradient(<direction - converted>, <from>, <to>);
* background-image: linear-gradient(<direction>, <from>, <to>);
*
* @example
* .selector {
* @include x-linear-gradient("to bottom", #ccc, #ddd, #bbb);
* }
*
* Note: By default this linear-gradient-mixin encourages people to use the
* latest CSS-syntax for gradients.
*/
@mixin x-linear-gradient ($direction: "to bottom", $fallback: #ccc, $from: #ccc, $to: #aaa) {
$directions: helper-gradient-angle($direction);
// Provide a fallback-color
background-color: $fallback;
// Cross-browser linear-gradients
background-image: -webkit-gradient(linear, unquote(nth($directions, 2)), from($from), to($to)); // Android 2.1-3.0
background-image: -webkit-linear-gradient(unquote(nth($directions, 1)), $from, $to);
background-image: -moz-linear-gradient(unquote(nth($directions, 1)), $from, $to);
background-image: -o-linear-gradient(unquote(nth($directions, 1)), $from, $to);
background-image: linear-gradient(unquote($direction), $from, $to);
}