• class的流光效果


    效果图:

    代码示例

    1. <!DOCTYPE html>
    2. <html lang="zh">
    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. * {
    9. margin: 0;
    10. padding: 0;
    11. }
    12. /* 流光效果 */
    13. .light {
    14. position: absolute;
    15. display: block;
    16. }
    17. .light:nth-child(1) {
    18. filter: hue-rotate(0deg);
    19. top: 0;
    20. left: 0;
    21. width: 100%;
    22. height: 3px;
    23. background: linear-gradient(90deg, transparent, #3a86ff);
    24. animation: animate1 8s linear infinite;
    25. }
    26. @keyframes animate1 {
    27. 0% {
    28. left: -100%;
    29. }
    30. 50%,
    31. 100% {
    32. left: 100%;
    33. }
    34. }
    35. .light:nth-child(2) {
    36. filter: hue-rotate(60deg);
    37. top: -100%;
    38. right: 0;
    39. width: 3px;
    40. height: 100%;
    41. background: linear-gradient(180deg, transparent, #3a86ff);
    42. animation: animate2 8s linear infinite;
    43. animation-delay: 2s;
    44. }
    45. @keyframes animate2 {
    46. 0% {
    47. top: -100%;
    48. }
    49. 50%,
    50. 100% {
    51. top: 100%;
    52. }
    53. }
    54. .light:nth-child(3) {
    55. filter: hue-rotate(120deg);
    56. bottom: 0;
    57. right: 0;
    58. width: 100%;
    59. background: linear-gradient(270deg, transparent, #3a86ff);
    60. animation: animate3 8s linear infinite;
    61. animation-delay: 4s;
    62. }
    63. @keyframes animate3 {
    64. 0% {
    65. right: -100%;
    66. height: 3px;
    67. }
    68. 50%,
    69. 100% {
    70. height: 2px;
    71. right: 100%;
    72. }
    73. }
    74. .light:nth-child(4) {
    75. filter: hue-rotate(300deg);
    76. bottom: -100%;
    77. left: 0;
    78. width: 3px;
    79. height: 100%;
    80. background: linear-gradient(360deg, transparent, #3a86ff);
    81. animation: animate4 8s linear infinite;
    82. animation-delay: 6s;
    83. }
    84. @keyframes animate4 {
    85. 0% {
    86. bottom: -100%;
    87. }
    88. 50%,
    89. 100% {
    90. bottom: 100%;
    91. }
    92. }
    93. .boxs {
    94. width: 100%;
    95. display: flex;
    96. justify-content: center;
    97. overflow: hidden;
    98. }
    99. .box {
    100. width: 300px;
    101. height: 300px;
    102. background-color: antiquewhite;
    103. text-align: center;
    104. }
    105. .box {
    106. position: relative;
    107. /* 让伪元素相对于.box定位 */
    108. overflow: hidden;
    109. /* 隐藏超出.box的部分 */
    110. }
    111. </style>
    112. </head>
    113. <body>
    114. <div class="boxs">
    115. <div class="box">
    116. <span class="light"></span><span class="light"></span><span class="light"></span><span class="light"></span>
    117. <p>流光效果</p>
    118. </div>
    119. </div>
    120. </body>
    121. </html>

    希望可以帮到大家

  • 相关阅读:
    在docker上安装AWVS
    VS Code C# 开发工具包正式发布
    Android 10开始不支持创建新的HIDL
    无胁科技-TVD每日漏洞情报-2022-11-10
    微信小程序 slot 不显示
    .Net7自定义GC垃圾回收器
    docker-compose部署mysql5.7主从
    机器学习——词向量模型(未开始)
    MaixII-Dock(v831)学习笔记——UART
    网页构造与源代码
  • 原文地址:https://blog.csdn.net/tianxianghuiwei/article/details/139844862