Last active
May 23, 2023 01:45
-
-
Save himynameisdave/32e51f5ff4780ae2104d to your computer and use it in GitHub Desktop.
Mixins for Animating Between Gradients
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
.gradient-animation( @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; | |
} | |
} | |
} |
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
@mixin gradient-animation( $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