Skip to content

Instantly share code, notes, and snippets.

@mnafricano
Created March 13, 2013 14:56
Show Gist options
  • Save mnafricano/5152904 to your computer and use it in GitHub Desktop.
Save mnafricano/5152904 to your computer and use it in GitHub Desktop.
A CodePen by Marcello Africano. Pure CSS Loading Spinner
<div class="spinner-wrap">
<div class="spinner">
<i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i>
</div>
</div>
/**
* Pure CSS Loading Spinner with CSS3 step()
*/
* {
margin: 0; padding: 0;
box-sizing: border-box;
}
body { background: #000; }
.spinner-wrap {
width: 100%;
position: absolute;
top: 50%;
}
.spinner {
height: 100px; width: 100px;
margin: -50px auto 0;
animation: spin 1s steps(12, end) infinite;
}
.spinner i {
height: 30px; width: 6px;
margin-left: -3px;
display: block;
position: absolute;
left: 50%;
transform-origin: center 50px;
background: #fff;
box-shadow: 0 0 3px rgba(255, 255, 255, .7);
border-radius: 2px;
}
.spinner i:nth-child(1) { opacity: 0.08; }
.spinner i:nth-child(2) { transform: rotate(30deg); opacity: 0.167; }
.spinner i:nth-child(3) { transform: rotate(60deg); opacity: 0.25; }
.spinner i:nth-child(4) { transform: rotate(90deg); opacity: 0.33; }
.spinner i:nth-child(5) { transform: rotate(120deg); opacity: 0.4167; }
.spinner i:nth-child(6) { transform: rotate(150deg); opacity: 0.5; }
.spinner i:nth-child(7) { transform: rotate(180deg); opacity: 0.583; }
.spinner i:nth-child(8) { transform: rotate(210deg); opacity: 0.67; }
.spinner i:nth-child(9) { transform: rotate(240deg); opacity: 0.75; }
.spinner i:nth-child(10) { transform: rotate(270deg); opacity: 0.833; }
.spinner i:nth-child(11) { transform: rotate(300deg); opacity: 0.9167; }
.spinner i:nth-child(12) { transform: rotate(330deg); opacity: 1; }
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment