<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>动画效果</title>
<link href="style.css" type="text/css" rel="stylesheet">
</head>
<body>
<div>动画效果</div>
</body>
</html>
div{
width:100px;
height:100px;
background-color:red;
position:relative;
animation:anim 5s infinite alternate;/*不断执行*/
-webkit-animation:anim 5s infinite alternate;
}
@keyframes anim{
0% {
background: red;
left: 0px;
top: 0px;
}
25% {
background: blue;
left: 20px;
top: 0px;
}
50% {
background: #CCFFCC;
left: 200px;
top: 200px;
}
75% {
background: #00FFFF;
left: 0px;
top: 200px;
}
100% {
background: red;
left: 0px;
top: 0px;
}
}
@-webkit-keyframes anim {
0% {
background: red;
left: 0px;
top: 0px;
}
25% {
background: blue;
left: 20px;
top: 0px;
}
50% {
background: #CCFFCC;
left: 200px;
top: 200px;
}
75% {
background: #00FFFF;
left: 0px;
top: 200px;
}
100% {
background: red;
left: 0px;
top: 0px;
}
}