0

I just started learning HTML5 and CSS3 and I'm trying to animate a small circle in a box. The animation worked but it is moving back to its initial position. I want the circle to the animated position.

<head>
<style type="text/css">

#green{
width:600px; height:600px; background-color:green;
}

.yellow{
width:100px; height:100px; border-radius:50%;
background-color:yellow; position:relative; top:10%; left:10%;
animation-name:move;
animation-duration:1s;  
}

@keyframes move{
from{transform:translateY(0)}
to{transform:translateY(-50px)}
}
</style>
</head>

<body>
<div id="green">
<div class="yellow"></div>
</div>
</body>

1 Answer 1

1

Your animation is done and skips to the initial position, add this underneath the animation-duration. It tells the animation to stop at the last frame

animation-fill-mode: forwards;

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.