Skip to content

Instantly share code, notes, and snippets.

@ricardozea
Last active July 16, 2018 03:03
Show Gist options
  • Save ricardozea/72bc4fc9cc070e96db92b7cc4726a0cd to your computer and use it in GitHub Desktop.
Save ricardozea/72bc4fc9cc070e96db92b7cc4726a0cd to your computer and use it in GitHub Desktop.
This could be used to animate gradient backgrounds on large buttons/CTAs
//Animated gradient background
//https://medium.com/@dave_lunny/animating-css-gradients-using-only-css-d2fd7671e759
//Usage:
//Example 1: include gradientAnimation(red, blue, .6s);
//Example 2: include gradientAnimation(lighten($orange, 10), $orange, .6s);
@mixin gradientAnimation( $start, $end, $transTime ){
background-size: 100%;
background-image: linear-gradient($start, $end);
position: relative;
z-index: 100;
&:before {
background-image: linear-gradient($end, $start);
content: "";
display: block;
height: 100%;
position: absolute;
top: 0; left: 0;
opacity: 0;
width: 100%;
z-index: -100;
transition: opacity $transTime;
}
&:hover {
&:before {
opacity: 1;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment