Created
June 12, 2013 14:51
-
-
Save jensgro/5765966 to your computer and use it in GitHub Desktop.
Linear-Gradient mixin for Sass, part of YAML (https://github.com/yamlcss/yaml/blob/master/sass/yaml-sass/mixins/_yaml-mixins-core.scss)
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
// --- | |
// Sass (v3.2.9) | |
// --- | |
// Linear Gradient with two colors for modern browsers without the corresponding IE-filter | |
// $direction ==> written in the standard-way: to bottom, to left ... | |
// $solid-color ==> replacement color for the one device that cannot show gradients or IE-filters | |
// $start-color ==> which color to start with | |
// $end-color ==> which color to end with | |
// $output ==> defines the output-type of the code | |
// css3 ==> only CSS3-gradients | |
// oldie ==> only IE-filters for oldIE (versions before 9) | |
// both ==> both CSS3 and oldIE versions are printed | |
// As there is a default direction there is no use for a fourth if-case. | |
@mixin ym-linear-gradient($direction: "to bottom", $start-color: #eee, $end-color: #ccc, $output: both) { | |
$old-direction: top; | |
$very-old-direction:"left top, left bottom"; | |
$ie-direction: 0; | |
@if $direction == "to right" { | |
$very-old-direction: "left top, right top"; | |
$old-direction: left; | |
$ie-direction: 1; | |
} | |
@if $output != "oldie" { | |
background: -webkit-gradient(linear, #{$very-old-direction}, color-stop(0%,$start-color), color-stop(100%,$end-color)); | |
background: -webkit-linear-gradient($old-direction, $start-color,$end-color); | |
background: -moz-linear-gradient($old-direction, $start-color,$end-color); | |
background: -ms-linear-gradient($old-direction, $start-color,$end-color); | |
background: linear-gradient($direction, $start-color,$end-color); | |
} | |
@if $output != "css3" { | |
$iecolor1: ie-hex-str($start-color); | |
$iecolor2: ie-hex-str($end-color); | |
filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=#{$ie-direction}, startColorstr='#{$iecolor1}', endColorstr='#{$iecolor2}'); | |
zoom: 1; | |
} | |
} | |
.test { | |
@include ym-linear-gradient(); | |
} | |
.test2 { | |
@include ym-linear-gradient("to right", #a20000, #000 ); | |
} |
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
.test { | |
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #eeeeee), color-stop(100%, #cccccc)); | |
background: -webkit-linear-gradient(top, #eeeeee, #cccccc); | |
background: -moz-linear-gradient(top, #eeeeee, #cccccc); | |
background: -ms-linear-gradient(top, #eeeeee, #cccccc); | |
background: linear-gradient("to bottom", #eeeeee, #cccccc); | |
filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC'); | |
zoom: 1; | |
} | |
.test2 { | |
background: -webkit-gradient(linear, left top, right top, color-stop(0%, #a20000), color-stop(100%, black)); | |
background: -webkit-linear-gradient(left, #a20000, black); | |
background: -moz-linear-gradient(left, #a20000, black); | |
background: -ms-linear-gradient(left, #a20000, black); | |
background: linear-gradient("to right", #a20000, black); | |
filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=1, startColorstr='#FFA20000', endColorstr='#FF000000'); | |
zoom: 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment