EMPOTECH
EMPOTECH
html
Copy
<!DOCTYPE html>
<html>
<head>
<style>
.ball {
width: 50px;
height: 50px;
background-color: red;
border-radius: 50%;
position: relative;
animation: bounce 2s infinite;
}
}
@keyframes bounce {
0% {
transform: translateY(0);
}
50% {
transform: translateY(-100px);
}
100% {
transform: translateY(0);
}
}
</style>
</head>
<body>
animation with a duration of 2 seconds, repeating
infinitely.
3. Keyframes:
- The @keyframes bounce block defines the animation's
keyframes.
- 0% (start of animation): The ball's vertical position is
translateY(0) , meaning it's at its initial position.
- 50% (midpoint of animation): The ball is translated
upwards by translateY(-100px) .
- 100% (end of animation): The ball returns to its
original position with translateY(0) .
<div class="ball"></div>
</body>
</html>
Explanation:
Further Exploration: