第一次看到这个动画效果根本不会做,但学了之后发现这也太简单了吧,总共才这么几行代码,简直信手拈来。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
width: 140px;
height: 140px;
background: url(./images/bg.png) no-repeat;
margin: 100px;
animation: run 1s steps(12) infinite, move 5s forwards;
}
@keyframes run {
to {
background-position: -1680px;
}
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>