CSS Properties: How to make an element move gradually down?

Go to Exercise page


HTML Code:

<!DOCTYPE html>
<title>How to make an element move gradually down</title>
<style type="text/css">
  width: 120px;
  height: 120px;
  background: #CC63FF;
  position :relative;
  -webkit-animation: mymove 5s infinite;
  animation: mymove 5s infinite;
@keyframes mymove {
  0%   {top: 0px;}
  25%  {top: 200px;}
  75%  {top: 50px}
  100% {top: 100px;}
<p><strong>w3resource Tutorial</strong></p>

Live Demo:

See the Pen keyframes-answer by w3resource (@w3resource) on CodePen.

See the solution in the browser

Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo
Yes Yes Yes Yes Yes

Go to Exercise page

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

Share this Tutorial / Exercise on : Facebook and Twitter

HTML-CSS: Tips of the Day

CSS height in percent not working :

You need to set a 100% height on all your parent elements, in this case your body and html. This fiddle shows it working.

html, body { height: 100%; width: 100%; margin: 0; }
div { height: 100%; width: 100%; background: #F52887; }


Ref: https://bit.ly/3vgtdfA