JSFiddle - React, Tailwind, and code Playground
HTML
<div class="contain-animation">
<div class="both-cars">
<div class="contain-car">
<div class="car-top car-top-2">
<div class="window window-2"></div>
<div class="window window-right window-right-2"></div>
</div>
<div class="car-bottom car-bottom-2">(1, start)</div>
<div class="tire tire-2">
<div class="tire-center tire-center-2"></div>
</div>
<div class="tire tire-right tire-right-2">
<div class="tire-center tire-center-2"></div>
</div>
</div>
<div class="contain-car contain-car-2">
<div class="car-top car-top-2">
<div class="window window-2"></div>
<div class="window window-right window-right-2"></div>
</div>
<div class="car-bottom car-bottom-2">(1, start, 50%)</div>
<div class="tire tire-2">
<div class="tire-center tire-center-2"></div>
</div>
<div class="tire tire-right tire-right-2">
<div class="tire-center tire-center-2"></div>
</div>
</div>
<div class="contain-car contain-car-3">
<div class="car-top car-top-2">
<div class="window window-2"></div>
<div class="window window-right window-right-2"></div>
</div>
<div class="car-bottom car-bottom-2">(2, start)</div>
<div class="tire tire-2">
<div class="tire-center tire-center-2"></div>
</div>
<div class="tire tire-right tire-right-2">
<div class="tire-center tire-center-2"></div>
</div>
</div>
</div>
</div>
CSS
.contain-animation {
height: 500px;
}
.both-cars {
position: relative;
border-left: 6px solid white;
border-right: 6px solid white;
width: 320px;
height: 350px;
}
.contain-car {
position: absolute;
width: 160px;
height: 110px;
animation: drive 4s steps(1, start) infinite;
}
.contain-car-2 {
margin-top: 110px;
animation: drive2 4s steps(1, start) infinite;
}
.contain-car-3 {
margin-top: 220px;
animation: drive3 4s steps(2, start) infinite;
}
.car-top {
position: absolute;
left: 35px;
border-radius: 50%;
background: #ed6e46;
width: 90px;
height: 80px;
}
.window {
position: absolute;
left: 10px;
top: 10px;
background: white;
border-radius: 100px 0 0 0;
width: 30px;
height: 30px;
}
.window-right {
left: 50px;
border-radius: 0 100px 0 0;
}
.car-bottom {
position: absolute;
top: 40px;
color: white;
background: #ed6e46;
font-family: 'Alegreya Sans', sans-serif;
font-size: 18px;
text-align: center;
border-radius: 100px 100px 10px 10px;
width: 160px;
height: 50px;
}
.tire {
position: absolute;
top: 60px;
left: 12px;
border-radius: 50%;
background: #333333;
width: 50px;
height: 50px;
}
.tire-right {
left: 98px;
}
.tire:after {
content: '';
display: block;
position: absolute;
left: 10px;
top: 10px;
background: gray;
border-radius: 50%;
width: 30px;
height: 30px;
}
.tire-center {
position: absolute;
left: 18px;
top: 15px;
width: 0;
height: 0;
border-left: 7px dotted transparent;
border-right: 7px dotted transparent;
border-bottom: 15px solid #333333;
z-index: 20;
}
.tire-center:after {
content: '';
display: block;
position: absolute;
left: -7px;
top: 5px;
width: 0;
height: 0;
border-left: 7px dotted transparent;
border-right: 7px dotted transparent;
border-top: 15px solid #333333;
}
@keyframes drive {
to {
transform: translateX(320px);
}
}
@keyframes drive2 {
50% {
transform: translateX(320px);
...