Create a captivating 2-second animation that alternates between a flashing blue light and a flashing red light. The blue light will flash for the first second (0-50% of animation time), while the red light will flash from 50-100% of the animation time.
Implement this effect using keyframes, following the example provided below.
To ensure the animation loops continuously, utilize the infinite
attribute;
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
width: 100vw;
margin: 0;
background-color: black;
}
div {
height: 50px;
width: 100px;
}
.blue {
animation: 2s infinite flashblue;
}
.red {
animation: 2s infinite flashred;
}
@keyframes flashblue {
0% {
background-color: lightblue;
}
25% {
background-color: darkblue;
}
50% {
background-color: lightblue;
}
100% {
background-color: lightblue;
}
}
@keyframes flashred {
0% {
background-color: salmon;
}
50% {
background-color: salmon;
}
75% {
background-color: firebrick;
}
100% {
background-color: salmon;
}
}
<div class="blue"></div>
<div class="red"></div>