在CSS中让动画只执行播放一次如何控制
Admin 2022-05-20 群英技术资讯 1877 次浏览
在css3中,可以利用animation-iteration-count属性来设置动画执行一次,该属性的作用就是定义动画的播放次数;当animation-iteration-count属性的值设置为数字“1”时,即可设置动画只播放一次。
本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。
在css3中,可以利用animation-iteration-count属性来设置动画执行一次。
animation-iteration-count属性可以定义动画的播放次数,设置动画应该播放多少次。
语法:
animation-iteration-count: value;
值 | 描述 |
---|---|
n | 一个数字,定义应该播放多少次动画 |
infinite | 指定动画应该播放无限次(永远) |
示例:
设置动画只播放一次
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> div { width: 100px; height: 100px; background: red; position: relative; animation: mymove 3s; animation-iteration-count: 1; /* Safari and Chrome */ -webkit-animation: mymove 3s; -webkit-animation-iteration-count: 1; } @keyframes mymove { from { top: 0px; } to { top: 200px; } } @-webkit-keyframes mymove /* Safari and Chrome */ { from { top: 0px; } to { top: 200px; } } </style> </head> <body> <div></div> </body> </html>
修改一下,设置动画播放3次
div { width: 100px; height: 100px; background: red; position: relative; animation: mymove 3s; animation-iteration-count: 3; /* Safari and Chrome */ -webkit-animation: mymove 3s; -webkit-animation-iteration-count: 3; }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
这篇文章主要介绍了用css实现正方形div 的两种方法,需要的朋友可以参考下
我们在HTML中设置frameset的高度时会出现界面变形的情况,那么设置frameset的高度界面变形怎么办呢?接下来我们就一起去看看设置frameset的高度界面变形的解决方法。
css元素垂直居中展示有哪些实现方法?在实际的项目中,实现元素垂直居中的需求还是比较常见的,而实现元素垂直居中的方法有很多,本文给大家分享几个方法,需要的朋友可以参考。
在css中,向左偏移的样式是“transform:translate(-向左偏移距离值);”;transform属性的作用是允许我们对元素进行旋转、缩放、移动或倾斜操作,translate()函数的作用是定义元素的平移转换。
这篇文章主要介绍了深入理解CSS @font-face性能优化,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008