Created
February 16, 2020 07:28
-
-
Save florianjs/3d073979f01ebf0c1d71f448e3fe94a3 to your computer and use it in GitHub Desktop.
Stars effect on Background
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="./styles.css" /> | |
<link | |
href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" | |
rel="stylesheet" | |
integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" | |
crossorigin="anonymous" | |
/> | |
<title>Dumb HTML</title> | |
</head> | |
<body class="stars"> | |
<script src="./assets/js/star.js"></script> | |
<script> | |
//refresh page on browser resize | |
$(window).bind('resize', function(e) { | |
if (window.RT) clearTimeout(window.RT); | |
window.RT = setTimeout(function() { | |
this.location.reload(false); /* false to get page from cache */ | |
}, 200); | |
}); | |
</script> | |
</body> | |
</html> |
This file contains hidden or 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
for (var i = 0; i < 100; i++) { | |
var star = | |
'<div class="star m-0" style="animation: twinkle ' + | |
(Math.random() * 5 + 5) + | |
's linear ' + | |
(Math.random() * 1 + 1) + | |
's infinite; top: ' + | |
Math.random() * $(window).height() + | |
'px; left: ' + | |
Math.random() * $(window).width() + | |
'px;"></div>'; | |
$('.homescreen').append(star); | |
} |
This file contains hidden or 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 { | |
position: absolute; | |
width: 2px; | |
height: 2px; | |
border-radius: 5px; | |
} | |
@keyframes twinkle { | |
0% { | |
transform: scale(1, 1); | |
background: rgba(255, 255, 255, 0); | |
animation-timing-function: linear; | |
} | |
40% { | |
transform: scale(0.8, 0.8); | |
background: rgba(255, 255, 255, 1); | |
animation-timing-function: ease-out; | |
} | |
80% { | |
background: rgba(255, 255, 255, 0); | |
transform: scale(1, 1); | |
} | |
100% { | |
background: rgba(255, 255, 255, 0); | |
transform: scale(1, 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment