Skip to content

Instantly share code, notes, and snippets.

@benschwarz
Created April 25, 2012 04:42
Show Gist options
  • Save benschwarz/2486433 to your computer and use it in GitHub Desktop.
Save benschwarz/2486433 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;
padding-top: 20px;
opacity: 0;
}
article:hover .transition {
opacity: 1;
padding-top: 0;
}
.anim {
float: right;
animation: hide 250ms forwards;
padding-top: 20px;
opacity: 0;
}
article:hover .anim {animation: show 250ms forwards;}
@keyframes hide {
0% {padding-top: 0; opacity: 1;}
100% {padding-top: 20px; opacity: 0;}
}
@keyframes show {
0% {padding-top: 20px; opacity: 0;}
100% {padding-top: 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","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