前端实现流星雨特效

举报
孙叫兽 发表于 2022/07/20 23:59:14 2022/07/20
【摘要】 目录 前言 效果图: HTML CSS 完整代码 前言 使用html+css实现简单得浏览器特效,在编译器用导入项目,直接在浏览器打开即可,效果十分得炫酷,十分得哇塞,女朋友直呼NB! 效果图: HTML <!DOCTYPE html><html lang="en"><...

目录

前言

效果图:

HTML

CSS

完整代码


前言

使用html+css实现简单得浏览器特效,在编译器用导入项目,直接在浏览器打开即可,效果十分得炫酷,十分得哇塞,女朋友直呼NB!

效果图:

HTML


  
  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>CSS Shooting Stars Animation</title>
  8. <link rel="stylesheet" type="text/css" href="style.css">
  9. </head>
  10. <body>
  11. <section>
  12. <span></span>
  13. <span></span>
  14. <span></span>
  15. <span></span>
  16. <span></span>
  17. <span></span>
  18. <span></span>
  19. <span></span>
  20. <span></span>
  21. <span></span>
  22. <span></span>
  23. <span></span>
  24. </section>
  25. </body>
  26. </html>

CSS


  
  1. *
  2. {
  3. margin: 0;
  4. padding: 0;
  5. box-sizing: border-box;
  6. }
  7. body
  8. {
  9. overflow: hidden;
  10. }
  11. section
  12. {
  13. position: absolute;
  14. top: 0;
  15. left: 0;
  16. width: 100%;
  17. height: 100vh;
  18. background: url(bg.jpg);
  19. background-position-x: center;
  20. background-size: cover;
  21. animation: animateBg 50s linear infinite;
  22. }
  23. @keyframes animateBg
  24. {
  25. 0%,100%
  26. {
  27. transform: scale(1);
  28. }
  29. 50%
  30. {
  31. transform: scale(1.2);
  32. }
  33. }
  34. span
  35. {
  36. position: absolute;
  37. top: 50%;
  38. left: 50%;
  39. width :4px;
  40. height: 4px;
  41. background: #fff;
  42. border-radius: 50px;
  43. box-shadow: 0 0 0 4px rgba(255,255,255,0.1),
  44. 0 0 0 8px rgba(255,255,255,0.1),
  45. 0 0 20px rgba(255,255,255,1);
  46. animation: animate 3s linear infinite;
  47. }
  48. span::before
  49. {
  50. content: "";
  51. position: absolute;
  52. top: 50%;
  53. transform: translateY(-50%);
  54. width: 300px;
  55. height: 1px;
  56. background: linear-gradient(90deg,#fff,transparent);
  57. }
  58. @keyframes animate
  59. {
  60. 0%
  61. {
  62. transform: rotate(315deg) translateX(0);
  63. opacity: 1;
  64. }
  65. 70%
  66. {
  67. opacity: 1;
  68. }
  69. 100%
  70. {
  71. transform: rotate(315deg) translateX(-1000px);
  72. opacity: 0;
  73. }
  74. }
  75. span:nth-child(1)
  76. {
  77. top: 0;
  78. right: 0;
  79. animation-delay: 0;
  80. animation-duration: 1s;
  81. }
  82. span:nth-child(2)
  83. {
  84. top: 0;
  85. right: 80px;
  86. left: initial;
  87. animation-delay: 0.2s;
  88. animation-duration: 3s;
  89. }
  90. span:nth-child(3)
  91. {
  92. top: 80px;
  93. right: 0;
  94. left: initial;
  95. animation-delay: 0.4s;
  96. animation-duration: 2s;
  97. }
  98. span:nth-child(4)
  99. {
  100. top: 0;
  101. right: 180px;
  102. left: initial;
  103. animation-delay: 0.6s;
  104. animation-duration: 1.5s;
  105. }
  106. span:nth-child(5)
  107. {
  108. top: 0;
  109. right: 400px;
  110. left: initial;
  111. animation-delay: 0.8s;
  112. animation-duration: 2.5s;
  113. }
  114. span:nth-child(6)
  115. {
  116. top: 0;
  117. right: 600px;
  118. left: initial;
  119. animation-delay: 1s;
  120. animation-duration: 3s;
  121. }
  122. span:nth-child(7)
  123. {
  124. top: 300px;
  125. right: 0;
  126. left: initial;
  127. animation-delay: 1.2s;
  128. animation-duration: 1.75s;
  129. }
  130. span:nth-child(8)
  131. {
  132. top: 0;
  133. right: 700px;
  134. left: initial;
  135. animation-delay: 1.4s;
  136. animation-duration: 1.25s;
  137. }
  138. span:nth-child(9)
  139. {
  140. top: 0;
  141. right: 1000px;
  142. left: initial;
  143. animation-delay: 0.75s;
  144. animation-duration: 2.25s;
  145. }
  146. span:nth-child(10)
  147. {
  148. top: 0;
  149. right: 450px;
  150. left: initial;
  151. animation-delay: 2.75s;
  152. animation-duration: 2.25s;
  153. }

完整代码

点我下载

小伙伴们赶紧下载体验吧!

文章来源: sunmenglei.blog.csdn.net,作者:孙叫兽,版权归原作者所有,如需转载,请联系作者。

原文链接:sunmenglei.blog.csdn.net/article/details/125881208

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。