- var n = 1;
section
while n <= 50
div.star(class='star-' + n)
div
- n++
// Randomized on every run!
@mixin star($size: 100px, $color: #000, $border-radius: 0) {
width: $size;
height: $size;
div {
width: $size;
height: $size;
position: relative;
background: $color;
border-radius: $border-radius;
}
div:before, div:after {
position: absolute;
top: 0;
left: 0;
width: $size;
height: $size;
content: '';
background: $color;
border-radius: $border-radius;
}
div:before { transform: rotate(30deg); }
div:after { transform: rotate(60deg); }
}
@keyframes rotate {
0% { transform: translateY(-50%) rotate(0deg); }
100% { transform: translateY(-50%) rotate(360deg); }
}
$total-elements: 50;
$starting-size: 400px;
$size-step: 15px, 10px, 5px;
$border-radius: $starting-size/50, $starting-size/20, $starting-size/10, 0;
$white: #ffffff;
$black: #333;
$gray: #6d6d6d;
$blue: #41A8DF;
$pink: #E72271;
$green: #5fc49e;
$red: #eb5a4f;
$orange: #f8a32c;
$purple: #a65cd4;
$colors: $white, $white, $white, $white, $white, $white, $red, $orange, $purple, $blue;
$durations: 140s, 120s, 100s, 80s;
@for $i from 1 through $total-elements {
.star-#{$i} {
@include star((($starting-size) - ($i * nth($size-step, random(length($size-step))))), nth($colors, random(length($colors))), nth($border-radius, random(length($border-radius))));
position: fixed;
top: 50%;
right: 0;
bottom: 0;
left: 0;
animation: rotate linear infinite;
opacity: 1;
display: block;
margin: 0 auto;
z-index: $i;
}
}
.star:nth-child(1n) { animation-duration: nth($durations, random(length($durations))); }
.star:nth-child(2n) { animation-duration: nth($durations, random(length($durations))); }
.star:nth-child(3n) { animation-duration: nth($durations, random(length($durations))); }
.star:nth-child(4n) { animation-duration: nth($durations, random(length($durations))); }
.star:nth-child(5n) { animation-duration: nth($durations, random(length($durations))); }
.star:nth-child(3n) { animation-direction: reverse; }
As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.
Also see: Tab Triggers