7_CSS3动画.html 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <style>
  8. .box{
  9. width: 200px;
  10. height: 50px;
  11. background-color: red;
  12. /* animation: foo 1s linear 2 forwards; */
  13. animation-name: foo;
  14. animation-duration: 1s;
  15. animation-timing-function: linear;
  16. animation-iteration-count: infinite;
  17. animation-fill-mode: forwards;
  18. animation-delay: 1s;
  19. }
  20. .box:hover{
  21. animation-play-state: paused;
  22. }
  23. @keyframes foo {
  24. 0%{
  25. width: 200px;
  26. height: 50px;
  27. }
  28. 50%{
  29. width: 400px;
  30. height: 50px;
  31. }
  32. 100%{
  33. width: 400px;
  34. height: 400px;
  35. }
  36. }
  37. /* @keyframes foo {
  38. from{
  39. width: 200px;
  40. }
  41. to{
  42. width: 400px;
  43. }
  44. } */
  45. </style>
  46. </head>
  47. <body>
  48. <div class="box"></div>
  49. </body>
  50. </html>