console
<div class="wrap">
<div class="traffic-light"></div>
</div>
body {
margin: 0;
position: absolute;
height: 100%;
width: 100%;
}
.wrap {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
width: 500px;
height: 350px;
background: rgb(97, 170, 189);
}
.traffic-light {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
text-align: center;
width: 300px;
height: 90px;
background: #282f2f;
border-radius: 50px;
box-shadow: 0 0 0 2px #eee inset;
}
.traffic-light::after {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
content: '';
display: inline-block;
width: 70px;
height: 70px;
border-radius: 50%;
animation: traffic-light 5s linear 0s infinite;
}
@keyframes traffic-light {
from {
background: transparent;
box-shadow:
-85px 0 0 0 transparent,
85px 0 0 0 transparent,
-85px 0 15px 0 transparent,
0px 0 15px 0 transparent,
85px 0 15px 0 transparent;
}
25% {
background: transparent;
box-shadow:
-85px 0 0 0 rgb(247, 78, 26),
85px 0 0 0 transparent,
-85px 0 15px 0 rgb(247, 78, 26),
0px 0 15px 0 transparent,
85px 0 15px 0 transparent;
}
50% {
background: rgb(231, 183, 78);
box-shadow:
-85px 0 0 0 transparent,
85px 0 0 0 transparent,
-85px 0 15px 0 transparent,
0px 0 15px 0 rgb(231, 183, 78),
85px 0 15px 0 transparent;
}
75% {
background: transparent;
box-shadow:
-85px 0 0 0 transparent,
85px 0 0 0 rgb(38, 175, 84),
-85px 0 15px 0 transparent,
0px 0 15px 0 transparent,
85px 0 15px 0 rgb(38, 175, 84);
}
to {
background: transparent;
box-shadow:
-85px 0 0 0 transparent,
85px 0 0 0 transparent,
-85px 0 15px 0 transparent,
0px 0 15px 0 transparent,
85px 0 15px 0 transparent;
}
}