Skip to content

Instantly share code, notes, and snippets.

@oli
Forked from benschwarz/dabblet.css
Created April 21, 2012 10:32
Show Gist options
  • Save oli/2436465 to your computer and use it in GitHub Desktop.
Save oli/2436465 to your computer and use it in GitHub Desktop.
duplicating a :hover transition using animation
/* 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;}
}
<article>
<menu class="transition"><a>A transitioning link</a></menu>
</article>
<article>
<menu class="anim"><a>An animating link</a></menu>
</article>
{"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