Skip to content

Instantly share code, notes, and snippets.

@laurendorman
Created December 28, 2015 16:15
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save laurendorman/2af852cd1eb92c713a1c to your computer and use it in GitHub Desktop.
Save laurendorman/2af852cd1eb92c713a1c to your computer and use it in GitHub Desktop.
Sass Mixins - Gradient Text, Borders and Backgrounds for Buttons
// $dir = Direction of gradient
// $from = Starting color
// $to = Ending color
// $width = Border width/thickness
@mixin border-gradient($dir, $from, $to, $width) {
border-left: $width solid $from;
border-right: $width solid $to;
background-image:
// Needed for both the top and bottom borders
-webkit-linear-gradient($dir, $from, $to),
-webkit-linear-gradient($dir, $from, $to);
background-size: 100% $width;
background-position: 0 100%, 0 0;
background-repeat: no-repeat;
background-clip: border-box;
}
@mixin background-gradient($dir, $from, $to) {
background-image:
-webkit-linear-gradient($dir, $from, $to),
}
@mixin text-gradient($dir, $from, $to) {
background: -webkit-linear-gradient($dir, $from, $to);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment