css实现div一直旋转的方法:首先创建一个div元素,并给它一个id值;然后使用内联样式给div添加一些样式;接着使用“@keyframes”规则创建一个动画rotate;最后给div指定animation即可。

本教程操作环境:windows7系统、HTML5&&CSS3版本,Dell G3电脑。
相关推荐:《css视频教程》
css实现div一直旋转
1、首先创建一个div元素,并给它一个id值xuanzhuan,使用内联样式给div添加一些样式。
<div id="xuanzhun" style="width: 30px; height: 30px; background-color: aquamarine;">

2、然后使用@keyframes规则创建一个动画rotate
@-webkit-keyframes rotate{
from{-webkit-transform: rotate(0deg)}
to{-webkit-transform: rotate(360deg)}
}
@-moz-keyframes rotate{
from{-moz-transform: rotate(0deg)}
to{-moz-transform: rotate(359deg)}
}
@-o-keyframes rotate{
from{-o-transform: rotate(0deg)}
to{-o-transform: rotate(359deg)}
}
@keyframes rotate{
from{transform: rotate(0deg)}
to{transform: rotate(359deg)}
}
3、最后,给div指定animation即可。
#xuanzhun{
-webkit-transition-property: -webkit-transform;
-webkit-transition-duration: 1s;
-moz-transition-property: -moz-transform;
-moz-transition-duration: 1s;
-webkit-animation: rotate 3s linear infinite;
-moz-animation: rotate 3s linear infinite;
-o-animation: rotate 3s linear infinite;
animation: rotate 3s linear infinite;
}
效果:

以上就是css实现div一直旋转的方法的详细内容,更多请关注php中文网其它相关文章!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
