02.动画_关键帧.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. .outer{
  10. height: 500px;
  11. border-bottom: 10px black solid;
  12. margin: 50px auto;
  13. overflow: hidden;
  14. }
  15. .outer div{
  16. float: left;
  17. width: 100px;
  18. height: 100px;
  19. border-radius: 50%;
  20. background-color: #bfa;
  21. animation: ball 1s forwards linear infinite alternate;
  22. }
  23. div .box2{
  24. background-color: orange;
  25. animation-delay: .1s;
  26. }
  27. div .box3{
  28. background-color: yellow;
  29. animation-delay: .2s;
  30. }
  31. div .box4{
  32. background-color: yellowgreen;
  33. animation-delay: .3s;
  34. }
  35. div .box5{
  36. background-color: blue;
  37. animation-delay: .4s;
  38. }
  39. div .box6{
  40. background-color: pink;
  41. animation-delay: .5s;
  42. }
  43. div .box7{
  44. background-color: tomato;
  45. animation-delay: .6s;
  46. }
  47. div .box8{
  48. background-color: skyblue;
  49. animation-delay: .7s;
  50. }
  51. div .box9{
  52. background-color: chocolate;
  53. animation-delay: .8s;
  54. }
  55. /* 创建小球下落的动画 */
  56. @keyframes ball{
  57. from{
  58. margin-top: 0;
  59. }
  60. 20%,60%,to{
  61. margin-top: 400px;
  62. animation-timing-function: ease-out;
  63. }
  64. 40%{
  65. margin-top: 100px;
  66. }
  67. 80%{
  68. margin-top: 200px;
  69. }
  70. }
  71. </style>
  72. </head>
  73. <body>
  74. <div class="outer">
  75. <div class="box1"></div>
  76. <div class="box2"></div>
  77. <div class="box3"></div>
  78. <div class="box4"></div>
  79. <div class="box5"></div>
  80. <div class="box6"></div>
  81. <div class="box7"></div>
  82. <div class="box8"></div>
  83. <div class="box9"></div>
  84. </div>
  85. </body>
  86. </html>