Categories
JavaScript Answers

How to rotate and scale an img at the same time with CSS?

Spread the love

Sometimes, we want to rotate and scale an img at the same time with CSS.

In this article, we’ll look at how to rotate and scale an img at the same time with CSS.

How to rotate and scale an img at the same time with CSS?

To rotate and scale an img at the same time with CSS, we use rotate and scale.

For instance, we write

<img class="rotate-img" src="https://picsum.photos/300/300" />

to add an img element.

Then we write

.rotate-img {
  -webkit-transform: rotate(90deg) scale(0.2);
  transform: rotate(90deg) scale(0.2);
  left: -200px;
  position: relative;
}

to select the rotate-img class and set its transform property to add the rotate and scale options.

Conclusion

To rotate and scale an img at the same time with CSS, we use rotate and scale.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *