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

本教程操作环境:windows7系统、HTML5&&CSS3版本,Dell G3电脑。
相关推荐:《css视频教程》
css实现div一直旋转
1、首先创建一个div元素,并给它一个id值xuanzhuan,使用内联样式给div添加一些样式。
<div>
<p><img src="https://img.php.cn/upload/image/921/983/160/1609901515326113.png?x-oss-process=image/resize,p_40" title="1609901515326113.png" alt="a2016409de012e750c60c87829c42ac.png"></p><div class="aritcle_card flexRow artxards">
<div class="artcardd flexRow">
<a class="aritcle_card_img" rel="nofollow" href="/xiazai/gongju/2905" title="CSS"><img
src="https://img.php.cn/upload/manual/000/969/633/6af2b1226ad9e733.png" alt="CSS" onerror="this.onerror='';this.src='/static/lhimages/moren/morentu.png'" ></a>
<div class="aritcle_card_info flexColumn">
<a rel="nofollow" href="/xiazai/gongju/2905" title="CSS" class="overflowclass">CSS</a>
<p class="overflowclass">CSS 官方网站入口。访问 W3C 的 CSS 页面,查看 CSS 标准、学习资料与工作组动态;CSS 是 Web 标准,无需下载安装。</p>
</div>
<a rel="nofollow" href="/xiazai/gongju/2905" title="CSS" class="aritcle_card_btn flexRow flexcenter"><b></b><span>下载</span>
</a>
</div>
</div>
<p>2、然后使用@keyframes规则创建一个动画rotate</p>
<pre class="brush:php;toolbar:false">@-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;
}
效果:

前端入门到VUE实战笔记:立即使用
在学习笔记中,你将探索 前端 的入门与实战技巧!










