JSFiddle - React, Tailwind, and code Playground
HTML
<div id="page">
<div id="box-first">
<div id="first">
</div>
</div>
<div id="box-second">
<div id="second">
</div>
</div>
</div>
CSS
#page {
margin-top: 50px;
width: 300px;
height: 200px;
background-color: #000;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
#box-first, #box-second {
width: 200px;
height: 50px;
background-color: #fff;
border-radius: 8px;
margin-top: 10px;
margin-bottom: 10px;
}
@keyframes first
{
0% {background-color: green; width: 0%}
33% {background-color: yellow; width: 33%}
66% {background-color: orange; width: 66%}
100% {background-color: red; width: 100%}
}
@keyframes second
{
0% {background-color: green; width: 0%}
33% {background-color: yellow; width: 33%}
66% {background-color: orange; width: 66%}
100% {background-color: red; width: 100%}
}
#first{
width: 100%;
height: 100%;
border-radius: 8px;
background-color: #fff;
animation: first 2s infinite;
}
#second {
width: 100%;
height: 100%;
border-radius: 8px;
background-color: #fff;
animation: second 2s infinite;
}