To rotate images continuously, we can use the css animation property.

Example : Rotate an image continuously using css #

In the above example, as you can see we have an <img> element with a class my-img.

  1. We have used the css animation property and set its name to rotateImg.
    .my-img{
       animation: rotateImg 2s linear infinite;
      }
  2. Now we will define the rotateImg function.
    @keyframes rotateImg {
      from {
        transform: rotate(0deg);
      }
      to {
        transform: rotate(359deg);
      }
    }
  3. 2s : it sets the animation duration.
  4. infinite : to rotate the image continuously.