A Pen by Razafindrakoto on CodePen.
Created
June 20, 2018 06:55
-
-
Save sedera-tax/f4b764876ed10d4adb1ee3627cdccd38 to your computer and use it in GitHub Desktop.
Sun
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="sun"> | |
<svg class="eclipse-container" viewBox="0 0 100 100"> | |
<circle class="eclipse" cx="50" cy="50" r="49" transform="rotate(-90 50 50)" /> | |
</svg> | |
</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
$yellow: #F6C744; | |
$duration: 20s; | |
$load-duration: 1s; | |
$length: 300; | |
.sun { | |
background-color: $yellow; | |
height: 50vmin; | |
width: 50vmin; | |
border-radius: 50%; | |
&:before { | |
content: ''; | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
animation: thats-no-moon $duration infinite, night-and-day $duration infinite; | |
background-color: #fff; | |
border-radius: 50%; | |
} | |
} | |
@keyframes thats-no-moon { | |
from, 5% { | |
transform: translateX(100%); | |
} | |
30%, 60% { | |
transform: none; | |
} | |
95%, to { | |
transform: translateX(-100%); | |
} | |
} | |
body { | |
animation: night-and-day $duration infinite; | |
} | |
.eclipse { | |
fill: none; | |
stroke: $yellow; | |
stroke-width: 2; | |
stroke-dasharray: $length #{$length*2}; | |
stroke-dashoffset: $length; | |
stroke-linecap: round; | |
animation: eclipse-reveal $duration cubic-bezier(.75,.02,.18,.98) infinite; | |
} | |
@keyframes eclipse-reveal { | |
0%, 30% { stroke-dashoffset: -$length; } | |
50% { stroke-dashoffset: 0; } | |
60%, 100% { stroke-dashoffset: $length; } | |
} | |
@keyframes night-and-day { | |
from, 5%, 95%, to { | |
background-color: white; | |
} | |
45%, 55% { | |
background-color: black; | |
} | |
} | |
html, body { | |
height: 100%; | |
width: 100%; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
overflow: hidden; | |
} | |
*, *:before { | |
box-sizing: border-box; | |
position: relative; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment