html animation source code
!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Animation</title>
<style>
/* Define the animation */
@keyframes example {
0% {background-color: red; left: 0px; top: 0px;}
50% {background-color: yellow; left: 200px; top: 0px;}
100% {background-color: red; left: 0px; top: 0px;}
}
/* Apply the animation to a div */
.box {
width: 100px;
height: 100px;
background-color: red;
position: relative;
animation-name: example;
animation-duration: 4s;
animation-iteration-count: infinite;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
In this code:
- We define a CSS animation called
example leusing@keyframes. - This animation gradually changes the background color and position of a box element.
- The animation is applied to a
divelement with the class.box. - The animation duration is set to 4 seconds, and it repeats infinitely.

Comments
Post a Comment