[SCSS] Milky Way effect

@use 'sass:math';
@use 'sass:string';

html {
  background: radial-gradient(ellipse at bottom, #1b2735 0%, #090a0f 100%);
  height: 100%;
  width: 100%;
  overflow: hidden;
}

@function createShadow($n) {
  $shadow: '#{math.random(100)}vw #{math.random(100)}vh #fff';
  @for $i from 2 through $n {
    $shadow: '#{$shadow}, #{math.random(100)}vw #{math.random(100)}vh #fff';
  }
  @return string.unquote($shadow);
}

$count: 1000;
$duration: 2000s;
@for $i from 1 through 5 {
  $count: math.floor(calc($count / 2));
  $duration: math.floor(calc($duration / 2));
.layer#{$i} {
  $size: #{$i}px;
  position: fixed;
  width: $size;
  height: $size;
  border-radius: 50%;
  left: 0;
  top: 0;
  box-shadow: createShadow($count);
  animation: moveUp $duration linear infinite;
  &::after {
    content: '';
    width: inherit;
    height: inherit;
    position: fixed;
    top: 100vh;
    left: 0;
    border-radius: inherit;
    box-shadow: inherit;
  }
}
}



@keyframes moveUp {
  100% {
    transform: translateY(-100vh);
  }
}
 <body>
     <div class="layer1"></div>
     <div class="layer2"></div>
     <div class="layer3"></div>
     <div class="layer4"></div>
     <div class="layer5"></div>
  </body>
posted @   Zhentiw  阅读(0)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
历史上的今天:
2024-02-15 [Rust] Macros vs. Functions
2024-02-15 [Rust] Error handling with Enum
2023-02-15 [Typescript] Creating Chainable Method Abstractions with Generics and the Builder Pattern - 05
2021-02-15 [Node] Install packages correctly and avoid attacks
2020-02-15 【时间管理】猴子理论 ”monkey-on-the-back” Analogy
2020-02-15 【时间管理】GTD:Getting things done
2019-02-15 [Webpack] Create Separate webpack Configs for Development and Production with webpack-merge
点击右上角即可分享
微信分享提示