CSS3:简易的循环弹跳动画
2015-09-08 00:01
603 查看
题外话
keyframes的小练习…相信对刚掌握了keyframes理论知识的有些帮助;百看不如一练,动手吧~~
注意: 建议用chrome或者chromium内核的浏览器进行浏览器,Firefox也行
基础理论
keyframes是CSS3才引进的 .. 使用方法是前面@keyframes Demo, Demo是自定义动画名字
仅支持百分比为进度条和form-to!!!!两者可以混用
animation有八个参数,可以分开写,可以综合写(一般一起写);
animation-name 规定 @keyframes 动画的名称。
animation-duration 规定动画完成一个周期所花费的秒或毫秒。默认是 0。
animation-timing-function 规定动画的速度曲线。默认是 “ease”。
animation-delay 规定动画何时开始。默认是 0。
animation-iteration-count 规定动画被播放的次数。默认是 1。
animation-direction 规定动画是否在下一周期逆向地播放。默认是 “normal”。
animation-play-state 规定动画是否正在运行或暂停。默认是 “running”。
animation-fill-mode 规定对象动画时间之外的状态。
综合写法:
animation : name 1s linear 1s inifinite alternate running both;
效果图
Live Demo
代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>keyframes</title> <style> .demo { width: 200px; height: 200px; text-align: center; line-height: 200px; background-color: #fe043c; position: relative; left: 50%; margin-left: -100px; -webkit-animation: Demo 6s ease-in-out infinite alternate running forwards; animation: Demo 6s ease-in-out infinite alternate running forwards; } .demo1 { width: 100px; height: 100px; text-align: center; line-height: 100px; background-color: #fe043c; position: absolute; left: 30%; margin-left: -100px; -webkit-animation: Demo1 6s ease-in-out infinite alternate running forwards; animation: Demo1 6s ease-in-out infinite alternate running forwards; } @-webkit-keyframes Demo { 20% { background-color: #f68c1b; top: 50px; border-radius: 20%; } 40% { background-color: #31b32c; top: 100px; border-radius: 40%; -webkit-transform: rotate(90deg) scale(1.4); transform: rotate(90deg) scale(1.4); } 60% { background-color: #1b8df6; top: 200px; border-radius: 60%; -webkit-transform: scale(.4) translateX(300); transform: scale(.4) translateX(300); } 80% { background-color: #ba38d5; top: 300px; border-radius: 80%; -webkit-transform: rotate(-90deg) scale(1.4); transform: rotate(-90deg) scale(1.4); } 100% { background-color: #2bbada; top: 400px; border-radius: 100%; } } @keyframes Demo { 20% { background-color: #f68c1b; top: 50px; border-radius: 20%; } 40% { background-color: #31b32c; top: 100px; border-radius: 40%; -webkit-transform: rotate(90deg) scale(1.4); transform: rotate(90deg) scale(1.4); } 60% { background-color: #1b8df6; top: 200px; border-radius: 60%; -webkit-transform: scale(.4) translateX(300); transform: scale(.4) translateX(300); } 80% { background-color: #ba38d5; top: 300px; border-radius: 80%; -webkit-transform: rotate(-90deg) scale(1.4); transform: rotate(-90deg) scale(1.4); } 100% { background-color: #2bbada; top: 400px; border-radius: 100%; } } @-webkit-keyframes Demo1 { form { background-color: #df5891; -webkit-transform: translateX(50px); transform: translateX(150px); border-radius: 25%; top: 100px; } 50% { -webkit-transform: scale(2); transform: scale(2); -webkit-transform: translateX(350px); transform: translateX(150px); background-color: #642eb1; border-radius: 35%; top: 200px; } 75% { -webkit-transform: scale(2); transform: scale(2.5); -webkit-transform: translateX(150px); transform: translateX(150px); background-color: #642eb1; border-radius: 55%; top: 400px; } to { background-color: #05823b; -webkit-transform: translateX(250px); transform: translateX(250px); border-radius: 75%; top: 600px; } } @keyframes Demo1 { form { background-color: #df5891; -webkit-transform: translateX(50px); transform: translateX(150px); border-radius: 25%; top: 100px; } 50% { -webkit-transform: scale(2); transform: scale(2); -webkit-transform: translateX(350px); transform: translateX(150px); background-color: #642eb1; border-radius: 35%; top: 200px; } 75% { -webkit-transform: scale(2); transform: scale(2.5); -webkit-transform: translateX(150px); transform: translateX(150px); background-color: #642eb1; border-radius: 55%; top: 400px; } to { background-color: #05823b; -webkit-transform: translateX(250px); transform: translateX(250px); border-radius: 75%; top: 600px; } } </style> </head> <body> <div class="demo">简易动画效果</div> <div class="demo1">啦啦德玛西亚</div> </body> </html>
相关文章推荐
- CSS样式规范
- css定位浮动 &html 严格模式混杂模式
- 一个简单div+css来练习
- 让label中的不同字符显示不同的样式
- CSS3 遮罩蒙版效果 分栏效果
- 深入理解CSS3 Animation 帧动画
- css position总结
- POI-----单元格常用样式
- CSS3实现图片超立体3D效果
- table换行
- 纯css实现仿ios表单开关
- 使用CSS修改HTML的checkbox效果的小示例分享
- CSS中的zoom属性和scale属性的用法及区别
- CSS 星号*
- 定位上下文(补充css的position属性)
- 推荐大家使用的CSS书写规范、顺序
- css+div三列宽度自适应
- css中单位px 、em、rem的区别
- 一些样式
- css代码仅在chrome浏览器中有效 / css中chrome浏览器兼容hack