Skip to content

Instantly share code, notes, and snippets.

@Sh00k-ThaD3v
Created February 2, 2023 08:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sh00k-ThaD3v/310183a85682aa296385e0e881478440 to your computer and use it in GitHub Desktop.
Save Sh00k-ThaD3v/310183a85682aa296385e0e881478440 to your computer and use it in GitHub Desktop.
Swaying loader
<div class="loader">
<span>Loading...</span>
</div>
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