Skip to content

Instantly share code, notes, and snippets.

@bloqhead
Created January 22, 2018 20:29
Show Gist options
  • Select an option

  • Save bloqhead/5e881bf7c3d16e6c4f72e1f8ba68271c to your computer and use it in GitHub Desktop.

Select an option

Save bloqhead/5e881bf7c3d16e6c4f72e1f8ba68271c to your computer and use it in GitHub Desktop.
//
// Animated gradients
//
// Adapted from: https://medium.com/@dave_lunny/animating-css-gradients-using-only-css-d2fd7671e759
//
@mixin animated-gradient(
$staticStart: null,
$staticEnd: null,
$hoverStart: null,
$hoverEnd: null,
$opacityOverride: null,
$transition: null,
$assembledStaticGradient: null,
$assembledHoverGradient: null
) {
position: relative;
z-index: 100;
@if $assembledStaticGradient != null {
background: $assembledStaticGradient;
}
@else {
background: linear-gradient($staticStart, $stacticEnd);
}
&:before {
position: absolute;
top: 0; left: 0;
z-index: -100;
content: "";
width: 100%;
height: 100%;
will-change: opacity;
@if $opacityOverride != null {
opacity: $opacityOverride;
}
@else {
opacity: 0;
}
border-radius: inherit;
@if $assembledHoverGradient != null {
background: $assembledHoverGradient;
}
@else {
background: linear-gradient($hoverStart, $hoverEnd);
}
transition: $transition;
}
&:hover:before {
opacity: 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment