Computer >> Computer tutorials >  >> Programming >> CSS

Perform Animation on CSS margin-right property


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

Example

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