动画实现 keyframes

  1. <style>
  2. * {
  3. padding: 0;
  4. margin: 0;
  5. }
  6. body {
  7. width: 100%;
  8. height: 100vh;
  9. display: grid;
  10. place-items: center;
  11. }
  12. div {
  13. width: 500px;
  14. height: 300px;
  15. background-color: #000;
  16. border-radius: 20px;
  17. box-shadow: 0 0 10px rgba(0, 0, 34, .5);
  18. /* animation: name duration timing-function delay iteration-count direction fill-mode; */
  19. animation: ppt 9s infinite linear;
  20. }
  21. @keyframes ppt {
  22. 0% {
  23. background: url(https://tva4.sinaimg.cn/large/0072Vf1pgy1foxkiqu05cj31hc0u0duy.jpg) no-repeat;
  24. background-size: cover;
  25. }
  26. 50% {
  27. background: url(https://tva1.sinaimg.cn/large/7f0c40d4gy1fqbf0e94b8j21hc0xc1ky.jpg) no-repeat;
  28. background-size: cover;
  29. }
  30. 100% {
  31. background: url(https://tva1.sinaimg.cn/large/0072Vf1pgy1fodqnbricvj31kw0vk7wh.jpg) no-repeat;
  32. background-size: cover;
  33. }
  34. }
  35. </style>
  36. <body>
  37. <div></div>
  38. </body>
  1. ![](https://cdn.jsdelivr.net/gh/Rr210/image@master/hexo/api/daw2131.gif#height=308&id=f9my4&margin=%5Bobject%20Object%5D&originHeight=410&originWidth=636&originalType=binary&ratio=1&status=done&style=shadow&width=477)