HTML CSS 烟熏效果
使用blur()函数对模糊效果进行动画处理。然后使用第n个子属性来应用动画延迟。

HTML代码

创建了一个div元素,并将加载文本字符包装在span元素内。

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content=
  6. "width=device-width, initial-scale=1.0" />
  7. <title>GeeksforGeeks</title>
  8. </head>
  9. <body>
  10. <div class="geeks">
  11. <span>G</span>
  12. <span>e</span>
  13. <span>e</span>
  14. <span>k</span>
  15. <span>s</span>
  16. <span>f</span>
  17. <span>o</span>
  18. <span>r</span>
  19. <span>G</span>
  20. <span>e</span>
  21. <span>e</span>
  22. <span>k</span>
  23. <span>s</span>
  24. </div>
  25. </body>
  26. </html>

CSS代码

  • 步骤1:将文本居中对齐作为背景。
  • 步骤2:提供了一个线性动画,其关键帧标识符为animate
  • 步骤3:使用关键帧将模糊功能应用于动画的不同帧。
  • 步骤4:最后一步是应用第n个子概念为每个角色提供动画延迟,以便在一个时间点只有一个角色变得模糊。

    1. <style>
    2. body {
    3. margin: 0;
    4. padding: 0;
    5. background: green;
    6. }
    7. .geeks {
    8. position: absolute;
    9. top: 50%;
    10. left: 50%;
    11. transform: translate(-50%, -50%);
    12. font-size: 30px;
    13. font-weight: 800;
    14. letter-spacing: 5px;
    15. }
    16. .geeks span {
    17. animation: animate 3s linear infinite;
    18. }
    19. .geeks span:nth-child(1) {
    20. animation-delay: 0s;
    21. }
    22. .geeks span:nth-child(2) {
    23. animation-delay: 0.1s;
    24. }
    25. .geeks span:nth-child(3) {
    26. animation-delay: 0.2s;
    27. }
    28. .geeks span:nth-child(4) {
    29. animation-delay: 0.3s;
    30. }
    31. .geeks span:nth-child(5) {
    32. animation-delay: 0.4s;
    33. }
    34. .geeks span:nth-child(6) {
    35. animation-delay: 0.5s;
    36. }
    37. .geeks span:nth-child(7) {
    38. animation-delay: 0.6s;
    39. }
    40. .geeks span:nth-child(8) {
    41. animation-delay: 0.9s;
    42. }
    43. .geeks span:nth-child(9) {
    44. animation-delay: 0.8s;
    45. }
    46. .geeks span:nth-child(10) {
    47. animation-delay: 0.9s;
    48. }
    49. .geeks span:nth-child(11) {
    50. animation-delay: 1s;
    51. }
    52. .geeks span:nth-child(12) {
    53. animation-delay: 1.1s;
    54. }
    55. .geeks span:nth-child(13) {
    56. animation-delay: 1.2s;
    57. }
    58. @keyframes animate {
    59. 0% {
    60. filter: blur(0);
    61. }
    62. 40% {
    63. filter: blur(20px);
    64. }
    65. 80% {
    66. filter: blur(0);
    67. }
    68. 100% {
    69. filter: blur(0);
    70. }
    71. }
    72. </style>

    完整的代码

    ```html <!DOCTYPE html>

G e e k s f o r G e e k s

```

效果

烟熏效果的实现 - 图1