本文摘自PHP中文网,作者藏色散人,侵删。
css让图片旋转的方法:首先创建一个HTML示例文件;然后通过img标签引入图片;最后通过给img图片添加transform和animation样式属性来实现图片旋转效果即可。
本文操作环境:windows7系统、HTML5&&CSS3版、Dell G3电脑。
我们可以给img图片添加了transform和animation样式属性来实现图片旋转效果。
示例:
HTML代码:
1 2 3 | <div class = "demo" >
<img class = "an img" src= "/test/img/2.png" width= "500" height= "500" />
</div>
|
css代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | .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;}
|
我们给img图片添加了transform和animation样式属性,使得图片实现360度旋转动画效果。
阅读剩余部分
相关阅读 >>
html css怎么设置字体大小
css 括号是什么
css怎么设置溢出不换行
jsp css图片不显示怎么办
css层叠性重要么
css怎么调整字体
css怎么设置不显示下边框
最受欢迎的10大css框架
css制作轮播图
css中用什么属性来定义盒的类型
更多相关阅读请进入《css》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » css如何让图片旋转