Syntax:
animation-timing-function: steps(number, [end | start])
Parameter description:
for instance:
If a line segment is divided into 10 parts, there are 11 points in total.
It seems that it is difficult to understand, then change the way of understanding
steps(number, [end | start]) Is to divide animation into
number Segment, total
number + 1 Frame screen.
start It means abandoning the first frame to execute animation,
end It means abandoning the last frame to execute the animation.
We will prepare a picture of the Iron Mountain
Look at my iron mountain!!!
<! doctype html> <html> <head> <meta charset="utf-8"> <title>Iron Mountain <style> * { padding: 0; margin: 0; } body { width: 100vw; height: 100vh; overflow: hidden; display: flex; justify-content: center; align-items: center; } .ikun { width: 480px; min-width: 480px; height: 270px; background: url(ikun.jpg) no-repeat; background-size: 100%; /* animation-name: mover1; */ animation-name: mover2; animation-duration: 2s; /* animation-timing-function: steps(10, start); */ animation-timing-function: steps(10, end); animation-iteration-count: infinite; animation-fill-mode: backwards; } /*Reverse order*/ @keyframes mover1 { from { background-position-y: -2700px; } to { background-position-y: 0; } } /*Positive sequence*/ @keyframes mover2 { from { background-position-y: 0; } to { background-position-y: -2700px; } } </style> </head> <body> <div class="ikun"> </div> </body> </html>