Square spinner
spinner of a project I'm working on.
<!--
<!--
autor: Marco Barría
https://twitter.com/marco_bf
-->
<div class="loading">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
$d: 40px;
$d: 40px;
$a: 2.3s;
$ease: cubic-bezier(0.690, 0.245, 0.185, 1.510);
$color: #fa8072, #fba440, #579fbb, #906b92;
$alpha: 0.8;
.loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: $d;
height: $d;
> div {
position: relative;
float: left;
width: $d/2;
height: $d/2;
animation-duration: $a;
animation-iteration-count: infinite;
animation-timing-function: $ease;
transform: scale(1) translateX(0px) translateY(0px) translateZ(0px);
opacity: $alpha;
&:nth-child(1) {
background-color: nth($color, 1);
transform-origin: top left;
animation-name: frame1;
}
&:nth-child(2) {
background-color: nth($color, 2);
transform-origin: top right;
animation-name: frame2;
}
&:nth-child(3) {
background-color: nth($color, 3);
transform-origin: bottom left;
animation-name: frame4;
}
&:nth-child(4) {
background-color: nth($color, 4);
transform-origin: bottom right;
animation-name: frame3;
}
}
}
frame1 {
0% {
transform: scale(1) translateX(0px) translateY(0px) translateZ(0px);
opacity: $alpha;
z-index: 10;
}
12.5% {
transform: scale(2) translateX(1px) translateY(1px) translateZ(0px);
opacity: 1;
z-index: 10;
}
25%, 100% {
transform: scale(1) translateX(0px) translateY(0px) translateZ(0px);
opacity: $alpha;
z-index: 0;
}
}
frame2 {
0%, 24.9%, 50%, 100% {
transform: scale(1) translateX(0px) translateY(0px) translateZ(0px);
opacity: $alpha;
z-index: 0;
}
25% {
transform: scale(1) translateX(0px) translateY(0px) translateZ(0px);
opacity: $alpha;
z-index: 10;
}
37.5% {
transform: scale(2) translateX(1px) translateY(1px) translateZ(0px);
opacity: 1;
z-index: 10;
}
}
frame3 {
0%, 49.9%, 75%, 100% {
transform: scale(1) translateX(0px) translateY(0px) translateZ(0px);
opacity: $alpha;
z-index: 0;
}
50% {
transform: scale(1) translateX(0px) translateY(0px) translateZ(0px);
opacity: $alpha;
z-index: 10;
}
62.5% {
transform: scale(2) translateX(-1px) translateY(-1px) translateZ(0px);
opacity: 1;
z-index: 10;
}
}
frame4 {
0%, 74.9%, 100% {
transform: scale(1) translateX(0px) translateY(0px) translateZ(0px);
opacity: $alpha;
z-index: 0;
}
75% {
transform: scale(1) translateX(0px) translateY(0px) translateZ(0px);
opacity: $alpha;
z-index: 10;
}
87.5% {
transform: scale(2) translateX(-1px) translateY(-1px) translateZ(0px);
opacity: 1;
z-index: 10;
}
}
html,
body {
height: 100%;
overflow: hidden;
}
body {
background-color: #1d2a38;
}