"Mesmerizing Bouncing Ball Animation | HTML CSS JavaScript Tutorial"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bouncing Ball Animation</title>
<style>
body, html {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
}
#container {
width: 200px;
height: 200px;
position: relative;
background-color: #f0f0f0;
}
#ball {
width: 50px;
height: 50px;
background-color: #3498db; /* Blue */
position: absolute;
border-radius: 50%;
animation: bounce 2s infinite alternate; /* Bouncing animation */
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
@keyframes bounce {
0% {
top: 0;
}
100% {
top: calc(100% - 50px); /* Ball reaches bottom */
}
}
</style>
</head>
<body>
<div id="container">
<div id="ball"></div>
</div>
<script>
// JavaScript can be used to control the animation dynamically if needed
</script>
</body>
</html>
Comments
Post a Comment