solution is to use both left
and margin-left
.square
{
width: 30px;
height: 3px;
background: red;
position: relative;
animation: colors 2s;
-webkit-animation: colors 2s;
animation-iteration-count: infinite;
-webkit-animation-iteration-count: infinite;
top: 0px;
margin-left:-30px;
}
@keyframes colors {
0% {left: 30px;}
99% { left: 100%;}
}
@-webkit-keyframes colors {
0% {left: 30px;}
99% { left: 100%;}
}