练习仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.5 KiB

1 day ago
  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. div{
  9. width: 200px;
  10. height: 200px;
  11. /*animation代表引入动画样式,mydh为自定义动画名,duration为动画持续时间; timing-function为动画播放速率(可取值为 ease逐渐变慢; linear匀速; ease-in加速; ease-out减速; ease-in-out先加速后减速) */
  12. /* delay表示延时执行时间; iteration-count为循环次数,infinite代表无限次执行 */
  13. animation: mydh 2s linear 0s infinite;
  14. }
  15. div:hover{
  16. /* 控制播放状态,running表示播放,paused代表暂停 */
  17. animation-play-state: paused;
  18. background-color: orange;
  19. }
  20. /*
  21. 使用 @keyframes创建动画,后跟自定义的动画名;下面的百分比可自定义添加对动画进度进行控制 */
  22. @keyframes mydh {
  23. 0%{
  24. /* 表示透明度。范围为0——1 */
  25. opacity: 0.1;
  26. background-color: brown;
  27. }
  28. 50%{
  29. opacity: 0.5;
  30. background-color: green;
  31. }
  32. 100%{
  33. opacity: 1;
  34. background-color: blue;
  35. }
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <div></div>
  41. </body>
  42. </html>