在style中先定义动画,后调用动画。
0%表示开始,100%表示结束。
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<style>
@keyframes move {
0% {
transform:translate(0,0);
}
25% {
transform: translate(100px,0);
}
50% {
transform: translate(100px,100px);
}
75% {
transform: translate(0,100px);
}
100% {
transform: translate(0,0);
}
}
div {
width:30px;
height:30px;
background-color:aquamarine;
animation-name:move;
animation-duration:10s;
animation-direction:alternate;
animation-iteration-count:infinite;
}
div:hover{
animation-play-state:paused;
}
</style>
</head>
<body>
<div></div>
</body>
</html>