Skip to content

Instantly share code, notes, and snippets.

@sanjeebtiwary
Created October 4, 2020 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanjeebtiwary/6ab3abcd1d466b44c936d65250700c9e to your computer and use it in GitHub Desktop.
Save sanjeebtiwary/6ab3abcd1d466b44c936d65250700c9e to your computer and use it in GitHub Desktop.
100 hr Challenge (CSS)
.wrapper
- for (i = 0; i < 100; i++)
hr
//rectangles or circles???
//uncomment border-radius and decide for yourself
body {
display: flex;
justify-content: center;
align-items: center;
width: 100vw;
height: 100vh;
background: black;
perspective: 300px;
overflow: hidden;
}
.wrapper {
position: absolute;
width: 100px;
height: 100px;
transform-origin: center;
transform-style: preserve-3d;
animation: rotate 60s linear infinite;
hr {
@for $i from 1 through 100 {
$x: random(300) - 150px;
$y: random(300) - 150px;
$z: random(300) - 150px;
$ry: random(90) - 0deg;
&:nth-child(#{$i}) {
position: absolute;
left: 0;
width: 150px;
//border-radius: 50%;
animation: hr#{$i}
30s
ease-in-out
#{1s *
($i - 100)}
infinite
alternate;
}
@keyframes hr#{$i} {
$glow: 0 0 5px hsla(random(255) + 100, random(100) + 60, 60, 1);
$glow2: 0 0 5px hsla(random(255) + 100, random(100) + 60, 60, 1);
0% {
border: solid 2px hsla(random(255) + 100, random(100) + 60, 60, 1);
box-shadow: $glow, $glow inset;
@if $i <= 50 {
transform: rotatey($ry) translate3d($x, $y, $z) rotate(0deg);
height: 20px;
} @else {
transform: rotatey($ry) translate3d($x, $y, $z) rotate(0deg);
width: random(50) + 0px;
height: 50px;
}
}
100% {
border: solid 2px hsla(random(255) + 100, random(100) + 60, 60, 1);
box-shadow: $glow2, $glow2 inset;
@if $i <= 50 {
transform: rotatey($ry)
translate3d($x, $y, $z)
rotate(random(270) - 270deg);
width: random(75) + 0px;
} @else {
transform: rotatey($ry)
translate3d($x, $y, $z)
rotate(random(270) - 270deg);
width: random(50) + 0px;
height: random(50) + 25px;
}
}
}
}
}
@keyframes rotate {
0% {
transform: rotateY(0deg);
}
100% {
transform: rotateY(360deg);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment