.box1{ width:200px; height:200px; background: #820000; color: #ffc; position:absolute; top:300px; left:0px;} .box2{ width:200px; height:200px; background: pink; position:absolute; top:300px; right:0px; -webkit-animation:animatedbox 15s infinite; animation:animatedbox 15s infinite;} @-webkit-keyframes animatedbox { 0%{right:0%;} 50%{right:100%;} 100%{right:0%;} } @keyframes animatedbox { 0%{right:0%;} 50%{right:100%;} 100%{right:0%;} }