Skip to content

Instantly share code, notes, and snippets.

@ryanburgess
Last active December 30, 2015 18:09
Show Gist options
  • Save ryanburgess/7865363 to your computer and use it in GitHub Desktop.
Save ryanburgess/7865363 to your computer and use it in GitHub Desktop.
Generate linear gradient code for all browsers by passing the top and bottom color values in the SASS mixin.
// -----------------------------------------
// Linear Gradients
// -------------------------------------------
// example: @include linearGradient(#cccccc, #333333);
@mixin linearGradient($top, $bottom){
background: $top; /* Old browsers */
filter: progid:DXImageTransform.Microsoft.gradient( GradientType=0, startColorstr=$top, endColorstr=$bottom ); /* IE6-9 */
background: -moz-linear-gradient(top, $top 0%, $bottom 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,$top), color-stop(100%,$bottom)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, $top 0%,$bottom 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, $top 0%,$bottom 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, $top 0%,$bottom 100%); /* IE10+ */
background: linear-gradient(to bottom, $top 0%,$bottom 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, startColorstr='#{$top}', endColorstr='#{$bottom}');
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$top}', endColorstr='#{$bottom}')";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment