Skip to content

Instantly share code, notes, and snippets.

@henadzit
Created October 14, 2015 14:31
Show Gist options
  • Save henadzit/310f6edd1e7ab8640bcf to your computer and use it in GitHub Desktop.
Save henadzit/310f6edd1e7ab8640bcf to your computer and use it in GitHub Desktop.
Bouncing box with CSS3
/*
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;
}
<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