
css如何实现div一直旋转?
1、首先创建一个div元素,并给它一个id值xuanzhuan,使用内联样式给div添加一些样式。
<div id="xuanzhun" style="width: 30px; height: 30px; background-color: aquamarine;">

(推荐学习:CSS视频教程)
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;
}效果:

更多CSS3相关技术文章,请访问CSS3答疑栏目进行学习!
以上就是css如何实现div一直旋转?的详细内容,更多请关注易知道|edz.cc其它相关文章!











