Skip to content

Instantly share code, notes, and snippets.

@herrkessler
Created May 15, 2014 07:26
Show Gist options
  • Save herrkessler/507ce9f4e5ba3debd5ad to your computer and use it in GitHub Desktop.
Save herrkessler/507ce9f4e5ba3debd5ad to your computer and use it in GitHub Desktop.
SASS stars (with a little JS)
#stars-wrapper
- 200.times do
.star
$(document).ready(function(){
$('.star').each(function(){
var X = 1 + Math.floor(Math.random() * 100);
var Y = 1 + Math.floor(Math.random() * 100);
var starSize = 1 + Math.floor(Math.random() * 50);
$(this).css({'left' : (X + '%'), 'top' : (Y + '%'), 'width' : (starSize + 'px'), 'height' : (starSize + 'px')});
});
});
=star($size, $color: white)
width: $size
height: $size
+background-image(radial-gradient(rgba($color,0.9) 5%, rgba($color,0.3) 15%, transparent 70%))
$colors: #635892 #BB6F93 #AC607C #694865 #C74031 #D1683C #E3A64D #C0C0C0
#stars-wrapper
position: absolute
top: 0
left: 0
right: 0
bottom: 0
background: #333
overflow: hidden
.star
+star(30px)
position: absolute
@each $color in $colors
$i: index($colors, $color)
&:nth-child(#{$i}), &:nth-child(#{$i*5}), &:nth-child(#{$i*3}), &:nth-child(#{$i*10}), &:nth-child(#{$i*2})
+star(30px, $color)
+animation(fadeOut #{$i}s ease-out infinite alternate forwards)
+animation-delay(#{$i}s)
opacity: 0.1
+keyframes(fadeOut)
from
opacity: 0.1
to
opacity: 1
@herrkessler
Copy link
Author

additional mixins are from bourbon.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment