I want to find out how to make a spinning or rotating image when it is hovered. I would like to know how to emulate that functionality with CSS on the following code :
img { border-radius: 50%; }
<img src="http://i.imgur.com/3DWAbmN.jpg" />
Rotating an image using CSS Once the CSS code is applied to your . css file, stylesheet, or <style> tags, you can use the CSS class name in any of your image tags. To rotate an image by another measure of degrees, change the "180" in the CSS code and <img> tag to the degree you desire.
Hover CSS lets you add hover effects to any element, such as a button, link or image. The effects include 2D transitions, background transitions, border, Shadow and Glow transitions, and more. The library is available in CSS, Sass, and LESS.
add "style="z-index: 1" to the object you're rotating and style="z-index: 2" (or any number higher than 1) to the text or whatever you want to display on top.
You can use CSS3 transitions with rotate()
to spin the image on hover.
img { transition: transform .7s ease-in-out; } img:hover { transform: rotate(360deg); }
<img src="https://i.stack.imgur.com/BLkKe.jpg" width="100" height="100"/>
Here is a fiddle DEMO
More info and references :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With