css3动画记录篇

PC端动画过度变换的兼容情况,用前阅读如下:(移动端由于手机迭代快,所以移动开发可不必考虑)

(1)transform:Chrome、Safari、Opera、Firefox、IE9 分别需要前缀 -webkit-、-o-、-moz-,-ms-。

(2)transition:Chrome、Safari、Opera、Firefox分别需要前缀-webkit-、-o-、-moz-,IE9不支持此属性

(3)@keyframes 规则 animation 属性:Chrome、Safari、Opera、Firefox、IE9 分别需要前缀 -webkit-、-o-、-moz-,IE9对此均不支持


1,上下移动

[html]  view plain  copy
  1. <!doctype html>  
  2. <html lang="en">  
  3. <head>  
  4.     <meta charset="UTF-8" />  
  5.     <title>Document</title>  
  6.     <style>  
  7.         .box{width: 100px;height: 100px;margin: 100px; background: yellow;}  
  8.         /*以下是时间段的分布0%到%50就是说这之间占有一半(50%)的时间,即Y轴0px到Y轴-50px用时为2s的一半,效果为上下移动*/  
  9.         @keyframes topBottomMove{  
  10.         0%   {  
  11.             transform: translateY(0px);   
  12.             }  
  13.         50%  {  
  14.          transform: translateY(-50px);  
  15.          }  
  16.         100% {  
  17.         transform: translateY(0px);   
  18.         }  
  19.     }  
  20.     .box {  
  21.         animation: topBottomMove 2s infinite ease-in-out;  
  22.     }  
  23.     </style>  
  24. </head>  
  25. <body>  
  26.     <div class="box"></div>  
  27. </body>  
  28. </html>  
2、360°无限循环
[html]  view plain  copy
  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4. <meta charset="utf-8" />  
  5. <title></title>  
  6. </head>  
  7. <body>  
  8. <style type="text/css">  
  9. *  
  10. {  
  11. margin:0;  
  12. padding:0;  
  13. text-align:center;   
  14. }  
  15.   
  16. @keyframes myRotate{  
  17. from{  
  18. transform:rotate(0deg);  
  19. }  
  20. to{  
  21. transform:rotate(360deg);  
  22. }  
  23. }   
  24. #box  
  25. {  
  26. width:300px;  
  27. height:300px;  
  28. margin: 300px auto;  
  29. border-radius: 50%;  
  30. /*linear为直线的,infinite则表示无限的*/  
  31. animation:myRotate .8s linear infinite;  
  32. color: white;  
  33. background:black;  
  34. }  
  35. </style>  
  36. <div id="box">  
  37. ABC  
  38. </div>  
  39. </body>  
  40. </html>  

3,放大缩小

[html]  view plain  copy
  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4. <meta charset="utf-8" />  
  5. <title></title>  
  6. </head>  
  7. <body>  
  8. <style type="text/css">  
  9. *  
  10. {  
  11. margin:0;  
  12. padding:0;  
  13. text-align:center;   
  14. }  
  15.   
  16. @keyframes mymove{  
  17.        0%   { transform: scale(1) }  
  18.        25%  { transform: scale(.8) }  
  19.        50%  { transform: scale(1.1) }  
  20.        75%  { transform: scale(.9) }  
  21.        100% { transform: scale(1) }  
  22.     }  
  23.     /*如果在vue上使用,需要实现触发一次就执行一次的话,则可以用:class='{move:move}',.move{animation: mymove .5s  infinite;},通过修改move的boolean值达到效果*/  
  24. #box  
  25. {  
  26. width:300px;  
  27. height:300px;  
  28. line-height: 300px;  
  29. margin: 300px auto;  
  30. border-radius: 50%;  
  31. font-size: 200px;  
  32. border: 5px solid red;  
  33. /*infinite则表示无限,ease-in-out则是执行一次*/  
  34. animation: mymove .5s  infinite;  
  35. color: white;  
  36. background:black;  
  37. }  
  38. </style>  
  39. <div id="box">  
  40. A  
  41. </div>  
  42. </body>  
  43. </html>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值