Created
September 5, 2016 16:16
-
-
Save L-canton/8c376213b82df81d90541a82aa2efe50 to your computer and use it in GitHub Desktop.
Twinkling Libra Constellation (CSS Only)
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
<div class='night-sky'> | |
<div class="star-box"> | |
<div class='star twinkle-star-1'></div> | |
<div class='star twinkle-star-2'></div> | |
<div class='star twinkle-star-3'></div> | |
<div class='star twinkle-star-4'></div> | |
<div class='star twinkle-star-5'></div> | |
<div class='star twinkle-star-6'></div> | |
<div class='star twinkle-star-7'></div> | |
<div class="line line-1"></div> | |
<div class="line line-2"></div> | |
<div class="line line-3"></div> | |
<div class="line line-4"></div> | |
<div class="line line-5"></div> | |
<div class="line line-6"></div> | |
<div class="line line-7"></div> | |
</div> | |
</div> |
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
// Constellation position and colors based on a NASA photo: | |
// http://www.constellation-guide.com/wp-content/uploads/2013/03/Libra-stars-and-location-of-HD-140283.jpg | |
// Star twinkle effect inspired by user @jeryj's codepen "Night Sky" http://codepen.io/jeryj/pen/YqyaJJ |
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
/* general styles */ | |
html { | |
height: 100%; | |
width: 100%; | |
margin: 0; | |
padding: 0; | |
} | |
body { | |
margin: 0; | |
padding: 0; | |
} | |
.night-sky { | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
height: 100vh; | |
width: 100%; | |
margin: 0; | |
padding: 0; | |
background: #111; | |
background: url('https://hd.unsplash.com/photo-1439923274069-a6f070db0c99'); | |
background-size: cover; | |
overflow: hidden; | |
} | |
.star-box { | |
width: 320px; | |
height: 360px; | |
position: relative; | |
margin: 0 auto; | |
} | |
/* star styling */ | |
.star { | |
position: absolute; | |
box-shadow: 0 0 3px #fff; | |
border-radius: 50%; | |
} | |
.twinkle-star-1 { | |
width: 5px; | |
height: 6px; | |
right: 16%; | |
top: 45%; | |
background: #b6c8ff; | |
-webkit-animation: twinkle 0.5s alternate infinite; | |
animation: twinkle 0.5s alternate infinite; | |
-webkit-animation-delay: 1.61404s; | |
animation-delay: 1.61404s; | |
} | |
.twinkle-star-2 { | |
right: 32%; | |
top: 84.5%; | |
width: 4px; | |
height: 4px; | |
background: #f4ccbf; | |
-webkit-animation: twinkle 0.5s alternate infinite; | |
animation: twinkle 0.5s alternate infinite; | |
-webkit-animation-delay: 4.09091s; | |
animation-delay: 4.09091s; | |
} | |
.twinkle-star-3 { | |
background: #f4ccbf; | |
width: 3px; | |
height: 3px; | |
left: 30%; | |
top: 97%; | |
-webkit-animation: twinkle 0.75s alternate infinite; | |
animation: twinkle 0.75s alternate infinite; | |
-webkit-animation-delay: 1.77143s; | |
animation-delay: 1.77143s; | |
} | |
.twinkle-star-4 { | |
width: 5px; | |
height: 5px; | |
left: 53%; | |
top: 16.8%; | |
background: #b6c8ff; | |
-webkit-animation: twinkle 0.5s alternate infinite; | |
animation: twinkle 0.5s alternate infinite; | |
-webkit-animation-delay: 1.55357s; | |
animation-delay: 1.55357s; | |
} | |
.twinkle-star-5 { | |
background: #f4aaaa; | |
width: 4px; | |
height: 4px; | |
left: 32%; | |
top: 40%; | |
-webkit-animation: twinkle 0.75s alternate infinite; | |
animation: twinkle 0.75s alternate infinite; | |
-webkit-animation-delay: 0.88462s; | |
animation-delay: 0.88462s; | |
} | |
.twinkle-star-6 { | |
background: #f4aaaa; | |
width: 3px; | |
height: 3px; | |
left: 10%; | |
top: 48.5%; | |
-webkit-animation: twinkle 0.5s alternate infinite; | |
animation: twinkle 0.5s alternate infinite; | |
-webkit-animation-delay: 0.66s; | |
animation-delay: 0.66s; | |
} | |
.twinkle-star-7 { | |
background: #b6c8f9; | |
width: 3px; | |
height: 3px; | |
left: 29%; | |
bottom: -4%; | |
-webkit-animation: twinkle 0.75s alternate infinite; | |
animation: twinkle 0.75s alternate infinite; | |
-webkit-animation-delay: 0.03279s; | |
animation-delay: 0.03279s; | |
} | |
/* line styling */ | |
.line { | |
width: 1px; | |
height: 1px; | |
position: absolute; | |
background: rgba(246,218,230,0.65); | |
-webkit-animation: line 7s alternate infinite; | |
animation: line 7s alternate infinite; | |
-webkit-animation-delay: 1s; | |
animation-delay: 1s; | |
} | |
.line-1 { | |
height: 215px; | |
transform: rotate(-10deg); | |
top: 21.5%; | |
left: 60.2%; | |
} | |
.line-2 { | |
height: 105px; | |
transform: rotate(-42deg); | |
top: 17%; | |
left: 68.5%; | |
} | |
.line-3 { | |
height: 119px; | |
transform: rotate(20deg); | |
top: 49%; | |
left: 75.5%; | |
} | |
.line-4 { | |
height: 75px; | |
transform: rotate(-142deg); | |
top: 19%; | |
left: 43%; | |
} | |
.line-5 { | |
height: 48px; | |
transform: rotate(69deg); | |
top: 38.2%; | |
left: 21.5%; | |
} | |
.line-6 { | |
height: 101px; | |
transform: rotate(69deg); | |
top: 77.5%; | |
left: 48%; | |
} | |
.line-7 { | |
height: 8px; | |
transform: rotate(9deg); | |
top: 99.5%; | |
left: 29.8%; | |
} | |
/* the keyframes! */ | |
@keyframes twinkle { | |
0% { | |
opacity: .45; | |
} | |
100% { | |
opacity: 1; | |
} | |
} | |
@keyframes line { | |
0% { | |
opacity: .5; | |
} | |
20% { | |
opacity: 0; | |
} | |
100% { | |
opacity: 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks