Animation code
<!--html code-->
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div class="container">
<div id="box1"></div>
<div id="circle"></div>
<div id="box2"></div>
</div>
</body>
</html>
<!--css code-->
.container{
width:390px;
height:600px;
background-color:beige;
border:2px solid black;
padding:5px;
margin:0px;
}
#box1{
width:70px;
height:30px;
background-color:aqua;
border:3px solid brown;
position:relative;
animation-name:rightmovement;
animation-duration:5s;
animation-delay:0s;
animation-iteration-count:infinite;
animation-fill-mode: none;
animation-play-state:running;
animation-direction: alternate;
animation-timing-function:linear;
}
@keyframes rightmovement{
from{
top:5%;
left:0%;
}
to{
top:5%;
left:85%;
}
}
#circle{
width:40px;
height:40px;
border:3px solid brown;
background-color:red;
border-radius:25px;
position: relative;
animation-name:circlemovement;
animation-duration:5s;
animation-delay:0s;
animation-iteration-count:infinite;
animation-direction:alternate;
animation-fill-mode:none;
animation-play-state:running;
animation-timing-function:linear;
}
@keyframes circlemovement{
0%{
top:75%;
left:5%;
}
25%{
top:7%;
left:85%;
}
60%{
top:7%;
left:5%;
}
100%{
top:75%;
left:85%;
}
}
#box2{
width:70px;
height:30px;
background-color:aqua;
border: 3px solid brown;
position: relative;
animation-name:leftmovement;
animation-duration:5s;
animation-delay:0s;
animation-iteration-count:infinite;
animation-direction:alternate;
animation-fill-mode:none;
animation-timing-function:linear;
animation-play-state: running;
}
@keyframes leftmovement{
from{
top:75%;
left:90%;
}
to{
top:75%;
left:10%;
}
}
}