FallingSnow.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <div class="winter-is-coming">
  3. <div class="snow snow--near"></div>
  4. <div class="snow snow--near snow--alt"></div>
  5. <div class="snow snow--mid"></div>
  6. <div class="snow snow--mid snow--alt"></div>
  7. <div class="snow snow--far"></div>
  8. <div class="snow snow--far snow--alt"></div>
  9. </div>
  10. </template>
  11. <style lang="less" scoped>
  12. .night-mode .winter-is-coming {
  13. background: var(--black);
  14. }
  15. /*Snow courtesy of iamjamie on codepen.io (https://codepen.io/iamjamie/pen/wzbEXG)*/
  16. .winter-is-coming,
  17. .snow {
  18. z-index: -1;
  19. pointer-events: none;
  20. }
  21. .winter-is-coming {
  22. overflow: hidden;
  23. position: fixed;
  24. top: 0;
  25. left: 0;
  26. right: 0;
  27. bottom: 0;
  28. background: rgb(240, 240, 240);
  29. }
  30. .snow {
  31. position: absolute;
  32. top: 0;
  33. right: 0;
  34. bottom: 0;
  35. left: 0;
  36. animation: falling linear infinite both;
  37. transform: translate3D(0, -100%, 0);
  38. }
  39. .snow--near {
  40. animation-duration: 10s;
  41. background-image: url("https://dl6rt3mwcjzxg.cloudfront.net/assets/snow/snow-large-075d267ecbc42e3564c8ed43516dd557.png");
  42. background-size: contain;
  43. }
  44. .snow--near + .snow--alt {
  45. animation-delay: 5s;
  46. }
  47. .snow--mid {
  48. animation-duration: 20s;
  49. background-image: url(https://dl6rt3mwcjzxg.cloudfront.net/assets/snow/snow-medium-0b8a5e0732315b68e1f54185be7a1ad9.png);
  50. background-size: contain;
  51. }
  52. .snow--mid + .snow--alt {
  53. animation-delay: 10s;
  54. }
  55. .snow--far {
  56. animation-duration: 30s;
  57. background-image: url(https://dl6rt3mwcjzxg.cloudfront.net/assets/snow/snow-small-1ecd03b1fce08c24e064ff8c0a72c519.png);
  58. background-size: contain;
  59. }
  60. .snow--far + .snow--alt {
  61. animation-delay: 15s;
  62. }
  63. @keyframes falling {
  64. 0% {
  65. transform: translate3D(-7.5%, -100%, 0);
  66. }
  67. 100% {
  68. transform: translate3D(7.5%, 100%, 0);
  69. }
  70. }
  71. </style>