css3--animation(動畫)
<!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>
.div1{
position: relative;
width: 100px;
height: 100px;
background-color:
animation: appMove 8s infinite; //appMove為宣告一個動畫變數,8s為0-100%的動畫持續時間,infinite為是否迴圈播放動畫
animation-direction:alternate; //是否逆向播放動畫0-100 再100-0,才是跑完一個動畫流程
}
@keyframes appMove{
//from to 為0-100的簡寫
/* from{
left: 0;
background-color:
}
to{
left: 100px;
background-color:
} */
0%{
left: 0px;
top: 0px;
background-color:
}
25%{
left: 100px;
top: 0px;
background-color:
}
50%{
left: 100px;
top: 100px;
background-color: green;
}
75%{
left: 0px;
top: 100px;
background-color: yellow;
}
100%{
left: 0px;
top: 0px;
background-color:
}
}
</style>
</head>
<body>
<div class="div1">
div1
</div>
</body>
</html>
複製程式碼