Since this can be a difficult debugging task, I would like to start with the same problem, but in an easier debugging environment.
I decided to do this as an animation of the rectangle above the full image.
.hi { width: 320px; height: 315px; background-image: url("http://i.stack.imgur.com/CjMscm.jpg"); position: relative; border: solid 1px black; } .hi:before { content: ""; position: absolute; width: 100%; height: 53px; left: 0px; top: 0px; border: solid 1px red; -webkit-animation: playv 18s steps(6) infinite; } @-webkit-keyframes playv { 0% { top: 0px; } 100% { top: 315px; } } .hi:after { content: ""; position: absolute; width: 53px; height: 100%; left: 266px; top: 0px; border: solid 1px red; -webkit-animation: playh 3s steps(6) infinite; } @-webkit-keyframes playh { 0% { left: 0px; } 100% { left: 320px; } }
<div class="hi"> </div>
In the image, I show 2 pseudo elements, one is a row selector and the other is a column selector. And I tweak the animation until they are ok
Now let's verify that setting both animations at the same time works:
.hi { width: 320px; height: 315px; background-image: url("http://i.stack.imgur.com/CjMscm.jpg"); position: relative; border: solid 1px black; } .hi:before { content: ""; position: absolute; width: 53px; height: 53px; left: 0px; top: 0px; border: solid 1px red; -webkit-animation: playv 18s steps(6) infinite, playh 3s steps(6) infinite; } @-webkit-keyframes playv { 0% { top: 0px; } 100% { top: 315px; } } @-webkit-keyframes playh { 0% { left: 0px; } 100% { left: 320px; } }
<div class="hi"> </div>
And here is the final draft:
.hi { width: 53px; height: 53px; background-image: url("http://i.stack.imgur.com/CjMscm.jpg"); position: relative; border: solid 1px black; -webkit-animation: playv 1s steps(6) infinite, playh 0.1667s steps(6) infinite; animation: playv 1s steps(6) infinite, playh 0.1667s steps(6) infinite; } @-webkit-keyframes playv { 0% { background-position-y: 0px; } 100% { background-position-y: -315px; } } @-webkit-keyframes playh { 0% { background-position-x: 0px; } 100% { background-position-x: -320px; } } @keyframes playv { 0% { background-position-y: 0px; } 100% { background-position-y: -315px; } } @keyframes playh { 0% { background-position-x: 0px; } 100% { background-position-x: -320px; } }
<div class="hi"> </div>
All this for the webkit browser, remove the prefixes for IE and FF. In addition, in this approach, it is impossible to avoid displaying two blank images in the lower left corner. If you do not have a full grid and you do not want to display blank images, you will need to specify all key frames one at a time
source share