
下面主要就给大家介绍用css3实现图片自动循环360旋转的具体方法
HTML代码示例如下:
<div class="demo">
<img class="an img" src="/test/img/2.webp" width="500" height="500"/>
</div>css图片旋转360度的动画代码示例如下:
.demo{
text-align: center;
margin-top: 100px;
}
@-webkit-keyframes rotation{
from {-webkit-transform: rotate(0deg);}
to {-webkit-transform: rotate(360deg);}
}
.an{
-webkit-transform: rotate(360deg);
animation: rotation 3s linear infinite;
-moz-animation: rotation 3s linear infinite;
-webkit-animation: rotation 3s linear infinite;
-o-animation: rotation 3s linear infinite;
}
.img{border-radius: 250px;}上述代码,可以直接复制粘贴在本地进行测试,那么通过浏览器访问,效果就如下图:

我们这里就要注意到animation属性,这个属性是所有动画属性的简写属性。我们给img图片添加了transform和animation样式属性,使得图片实现360度旋转动画效果。
css动画图片自动旋转的效果实现方法,也就如上所述。只要掌握了css中的transform和animation属性就可以实现大多数动画效果。他们的原理基本都是大同小异。
更多web开发知识,请查阅 HTML中文网 !!
以上就是css3如何让图片不停旋转?的详细内容,更多请关注易知道|edz.cc其它相关文章!













