-
-
Save oli/2436465 to your computer and use it in GitHub Desktop.
duplicating a :hover transition using animation
This file contains hidden or 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
/* duplicating a :hover transition using animation */ | |
article {border: 1px solid red; min-height: 100px;} | |
.transition { | |
float: right; | |
transition: all 250ms; | |
margin-top: 20px; | |
opacity: 0; | |
} | |
article:hover .transition { | |
opacity: 1; | |
margin-top: 0; | |
} | |
.anim { | |
float: right; | |
animation: hide 250ms forwards; | |
margin-top: 0; | |
opacity: 0; | |
} | |
article:hover .anim {animation: show 250ms forwards;} | |
@keyframes hide { | |
0% {transform: translateY(0); opacity: 1;} | |
100% {transform: translateY(20px); opacity: 0;} | |
} | |
@keyframes show { | |
0% {transform: translateY(20px); opacity: 0;} | |
100% {transform: translateY(0); opacity: 1;} | |
} | |
This file contains hidden or 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
<article> | |
<menu class="transition"><a>A transitioning link</a></menu> | |
</article> | |
<article> | |
<menu class="anim"><a>An animating link</a></menu> | |
</article> |
This file contains hidden or 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
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment