Spin or rotate an image on hover(悬停时旋转或旋转图像)
本文介绍了悬停时旋转或旋转图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想了解如何在悬停时制作旋转或旋转图像.我想知道如何在以下代码中使用 CSS 模拟该功能:
img {边界半径:50%;}
<img src="http://i.imgur.com/3DWAbmN.jpg"/>
上一页>
解决方案
您可以使用 CSS3 过渡和 rotate()
来在悬停时旋转图像.
旋转图片:
img {过渡:转换 .7s 缓进出;}图像:悬停{变换:旋转(360度);}
<img src="https://i.stack.imgur.com/BLkKe.jpg" width="100" height="100"/>
这是一个小提琴DEMO
更多信息和参考:
- MDN 上的 CSS 过渡指南
- MDN
- caniuse.com 上的 2d 转换浏览器支持表
- caniuse.com 上的过渡浏览器支持表
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" />
解决方案
You can use CSS3 transitions with rotate()
to spin the image on hover.
Rotating image :
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 :
- a guide about CSS transitions on MDN
- a guide about CSS transforms on MDN
- browser support table for 2d transforms on caniuse.com
- browser support table for transitions on caniuse.com
这篇关于悬停时旋转或旋转图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:悬停时旋转或旋转图像
基础教程推荐
猜你喜欢
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 响应更改 div 大小保持纵横比 2022-01-01
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 我什么时候应该在导入时使用方括号 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 动态更新多个选择框 2022-01-01
- 悬停时滑动输入并停留几秒钟 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- 在for循环中使用setTimeout 2022-01-01