Home > Web Front-end > CSS Tutorial > How to Create an Image Spin or Rotation Effect on Hover Using CSS?

How to Create an Image Spin or Rotation Effect on Hover Using CSS?

Mary-Kate Olsen
Release: 2024-11-04 22:26:02
Original
324 people have browsed it

How to Create an Image Spin or Rotation Effect on Hover Using CSS?

Emulating Image Spin or Rotation on Hover Using CSS

To achieve the desired spinning or rotating effect on an image when hovered, CSS can be utilized with specific properties and transitions. Here's how it could be implemented:

Code Implementation

<code class="css">img {
  border-radius: 50%;
  transition: transform .7s ease-in-out;
}
img:hover {
  transform: rotate(360deg);
}</code>
Copy after login

In the provided HTML code, each image element is modified using the above CSS styles:

<code class="html"><img src="http://i.imgur.com/3DWAbmN.jpg" />
<img src="https://i.sstatic.net/BLkKe.jpg" width="100" height="100" /></code>
Copy after login

Explanation

  • Border-radius: Sets the image to a circular shape (50% border-radius).
  • Transition: Defines the smooth transition of the image's transformation on hover (duration and easing function).
  • Transform: Rotate: On hover, the image's transformation property is set to rotate 360 degrees, causing it to spin.

This CSS implementation allows the image to smoothly rotate around its center when the mouse hovers over it.

The above is the detailed content of How to Create an Image Spin or Rotation Effect on Hover Using CSS?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template