Created
October 14, 2015 14:31
-
-
Save henadzit/310f6edd1e7ab8640bcf to your computer and use it in GitHub Desktop.
Bouncing box with CSS3
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
/* | |
Example https://jsfiddle.net/spxkmwau/ | |
*/ | |
@-webkit-keyframes bounce { | |
0%, | |
20%, | |
50%, | |
80%, | |
100% { | |
-webkit-transform: translateY(0); | |
} | |
40% { | |
-webkit-transform: translateY(-2px); | |
} | |
60% { | |
-webkit-transform: translateY(-2px); | |
} | |
} | |
@keyframes bounce { | |
0%, | |
20%, | |
50%, | |
80%, | |
100% { | |
transform: translateY(0); | |
} | |
40% { | |
transform: translateY(-2px); | |
} | |
60% { | |
transform: translateY(-2px); | |
} | |
} | |
.bounce { | |
-webkit-animation-name: bounce; | |
animation-name: bounce; | |
-webkit-animation-duration: 0.5s; | |
animation-duration: -0.5s; | |
-webkit-animation-fill-mode: both; | |
animation-fill-mode: both; | |
animation-iteration-count: infinite; | |
-webkit-animation-iteration-count: infinite; | |
} | |
.box { | |
width: 150px; | |
height: 30px; | |
border: 1px solid black; | |
text-align: center; | |
} |
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
<div class="box bounce">Click me!</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment