Created
May 15, 2014 07:26
-
-
Save herrkessler/507ce9f4e5ba3debd5ad to your computer and use it in GitHub Desktop.
SASS stars (with a little JS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#stars-wrapper | |
- 200.times do | |
.star |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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')}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
additional mixins are from bourbon.io