<div class="system">
<div class="planets">
<div class="sun"></div>
<div class="planet-1"></div>
<div class="planet-2"></div>
</div>
</div>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.system {
display: flex;
width: 100vw;
height: 100vh;
align-items: center;
justify-content: center;
}
.planets {
position: relative;
}
.planets:after,
.planets:before {
content: "";
position: absolute;
border-radius: 50%;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
border: 1px solid rgba(0,0,0,0.1);
}
.planets:before {
width: 220px;
height: 220px;
}
.planets:after {
width: 280px;
height: 280px;
}
.sun {
width: 160px;
height: 160px;
border-radius: 50%;
background: orange;
}
@keyframes orbit1 {
from {
transform: rotate(0deg) translateX(110px);
}
to {
transform: rotate(360deg) translateX(110px);
}
}
@keyframes orbit2 {
from {
transform: rotate(-90deg) translateX(140px);
}
to {
transform: rotate(270deg) translateX(140px);
}
}
.planet-1,
.planet-2 {
position: absolute;
z-index: 1;
border-radius: 50%;
left: 0;
top: 0;
right: 0;
bottom: 0;
margin: auto;
}
.planet-1 {
width: 40px;
height: 40px;
background: green;
animation: orbit1 10s linear infinite;
}
.planet-2 {
width: 20px;
height: 20px;
background: brown;
animation: orbit2 15s linear infinite;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.