Animate CSS margin-left property



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

Example

Live Demo

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

Advertisements