bear.png

代码

  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. body {
  10. background-color: #ccc;
  11. }
  12. div {
  13. position: absolute;
  14. width: 200px;
  15. height: 100px;
  16. background: url(media/bear.png) no-repeat;
  17. animation: bear 2s steps(8) infinite, move 5s forwards;
  18. }
  19. @keyframes bear {
  20. 0% {
  21. background-position: 0 0;
  22. }
  23. 100% {
  24. background-position: -1600px 0;
  25. }
  26. }
  27. @keyframes move {
  28. 0% {
  29. left: 0;
  30. }
  31. 100% {
  32. left: 50%;
  33. transform: translateX(-50%);
  34. }
  35. }
  36. </style>
  37. </head>
  38. <body>
  39. <div></div>
  40. </body>
  41. </html>