What you looking for is @keyframe.
Here is simmilar problem
CSS background color keyframes animation
@keyframes animation {
0% {background-color:red;}
50.0% {background-color:blue;}
100.0% {background-color:red;}
}
I think keyframes works pretty well for this one, here is example:
https://codepen.io/jerrykck/pen/eYZERPe
1
solved Change Background Color & Font Color Automatically Via CSS [closed]