Perform Animation on CSS margin-top


To implement animation on margin-top property with CSS, you can try to run the following code

Example

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            background-color: orange;
            animation: myanim 4s infinite;
            color: white;
         }
         @keyframes myanim {
            30% {
               margin-top: 30px;
            }
         }
      </style>
   </head>
   <body>
      <h2>Heading One</h2>
      <div>
         This is demo text.
      </div>
   </body>
</html>

Updated on: 25-Jun-2020

979 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements