I needed to implement infinite bounce effect using pure CSS, so I referred this site and ended up doing this.
Here is code not using the percentage in the keyframes. Because you used percentages the animation does nothing a long time.
How does this example work:
animation. This is a short hand for animation properties.from and to in the keyframes. from is = 0% and to is = 100%animation: bounce 1s infinite alternate; the 1s is how long the animation will last..ball {
margin-top: 50px;
border-radius: 50%;
width: 50px;
height: 50px;
background-color: cornflowerblue;
border: 2px solid #999;
animation: bounce 1s infinite alternate;
-webkit-animation: bounce 1s infinite alternate;
}
@keyframes bounce {
from {
transform: translateY(0px);
}
to {
transform: translateY(-15px);
}
}
@-webkit-keyframes bounce {
from {
transform: translateY(0px);
}
to {
transform: translateY(-15px);
}
}