本文摘自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度旋转动画效果。
阅读剩余部分
相关阅读 >>
css如何设置div不换行
css怎么设置字体发光效果
css怎样设置图片之间的间隔
css中skew是什么意思
css top属性怎么用
css怎么设置文件编码
less与sass框架如何使用?
css文本怎么设置水平对齐
css如何实现一个自适应容器
css写在html里面吗?
更多相关阅读请进入《css》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » css如何让图片旋转