JSFiddle - React, Tailwind, and code Playground
HTML
<div class="rotor">
<div class="red"></div>
<div class="blue"></div>
<div class="green"></div>
<div class="yellow"></div>
</div>
CSS
body{
background-color: #000;
}
.rotor{
position: absolute;
animation: rotor 4s normal linear infinite;
transform: rotate(100deg);
top: 50%;
left: 50%;
margin-top: -75px;
margin-left: -75px;
height: 150px;
width: 150px;
}
.red, .blue, .green, .yellow{
position: absolute;
height: 50px;
width: 50px;
top: 0px;
left: 50px;
background-color: rgba(3, 152, 39, 1);
border-radius: 25px;
transform-origin: 0 0px;
animation: red-green 1s linear infinite normal;
}
.red{
top: 100px;
left: 50px;
background-color: rgba(211, 13, 33, 1);
transform-origin: 0 50px;
animation: red-green 1s linear infinite normal;
}
.blue{
top: 50px;
left: 100px;
background-color: rgba(52, 103, 235, 1);
transform-origin: 50px 0;
animation: blue-yellow 1s linear infinite normal;
}
.yellow{
top: 50px;
left: 0px;
transform-origin: 0 0;
background-color: rgba(242, 177, 18, 1);
animation: blue-yellow 1s linear infinite normal;
}
@keyframes red-green{
50%{
top: 50px;
transform: rotate3d(0, 0, 0, 180deg);
opacity: 0.8;
}
100%{
top: 50px;
transform: rotate3d(2, 0, 0, 180deg);
}
}
@keyframes blue-yellow{
50%{
left: 50px;
transform: rotate3d(0, 0, 0, 180deg);
opacity: 0.8;
}
100%{
left: 50px;
transform: rotate3d(0, 2, 0, 180deg);
}
}
@keyframes rotor{
100%{
transform: rotate(460deg);
}
}