Watch interactive video on Scrimba: https://scrimba.com/p/pEgDAM/cqwpQh7
Created
February 2, 2023 08:11
-
-
Save Sh00k-ThaD3v/310183a85682aa296385e0e881478440 to your computer and use it in GitHub Desktop.
Swaying loader
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
<div class="loader"> | |
<span>Loading...</span> | |
</div> |
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
body { | |
margin: 0; | |
height: 100vh; | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
background-color: black; | |
overflow: hidden; | |
} | |
.loader { | |
width: 10em; | |
height: 10em; | |
font-size: 25px; | |
box-sizing: border-box; | |
border-top: 0.3em solid hotpink; | |
border-radius: 50%; | |
position: relative; | |
animation: rotating 2s ease-in-out infinite; | |
--direction: 1; | |
} | |
.loader::before, | |
.loader::after { | |
content: ''; | |
position: absolute; | |
width: inherit; | |
height: inherit; | |
border-radius: 50%; | |
box-sizing: border-box; | |
top: -0.2em; | |
} | |
.loader::before { | |
border-top: 0.3em solid dodgerblue; | |
transform: rotate(120deg); | |
} | |
.loader::after { | |
border-top: 0.3em solid gold; | |
transform: rotate(240deg); | |
} | |
.loader span { | |
position: absolute; | |
color: white; | |
width: inherit; | |
height: inherit; | |
text-align: center; | |
line-height: 10em; | |
font-family: sans-serif; | |
animation: rotating 2s linear infinite; | |
--direction: -1; | |
} | |
@keyframes rotating { | |
50% { | |
transform: rotate(calc(180deg * var(--direction))); | |
} | |
100% { | |
transform: rotate(calc(360deg * var(--direction))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment