Consider this sample.
http://jsfiddle.net/dfabulich/ncbzz5zu/3/
<html>
<body>
<style>
.container {
position: relative;
width: 80%;
height: 100px;
border: 1px solid black;
}
@keyframes slide {
from { background-color: red; left: 0; }
to { background-color: blue; right: 0; }
}
.animated {
position: absolute;
width: 20%;
height: 100%;
top: 0;
background-color: red;
animation-duration: 3s;
animation-name: slide;
animation-iteration-count: infinite;
}
</style>
<div class=container>
<div class=animated>
</div></div>
Expected: the red rectangle should smoothly animate from left to right, as the color changes from red to blue.
In fact: in Chrome / Firefox, the red rectangle slowly changes color to purple, then teleports from left to right without animation, and then slowly changes from purple to blue. In Safari, the rectangle appears on the right and never moves from there when animating from red to blue.
Why is this happening? How can i fix this? (I need to fix this in CSS ... no JS, no jQuery.)
source
share