通过transform可以设置多个移动的特性,完成一个小车行驶的效果
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
text-decoration: none;
list-style: none;
}
body {
perspective: 1000px;
}
img {
height: 200px;
width: 200px;
background-color: #ecc;
animation: firl 3s infinite ;
}
@keyframes firl {
0% {
transform: translate3d(0,0,0);
}
25% {
transform: translate3d(500px,0,0);
}
26% {
transform:translate3d(500px,0,0) rotateY(180deg);
}
100% {
transform:translate3d(0,0,0) rotateY(180deg);
}
}
</style>
</head>
<body>
<img src="timg.jpg" alt="">
</body>
</html>
效果图如下