標籤:
animation-name:自訂動畫名稱;
keyframes:主要畫面格;
animation-iteration-count:動畫執行次數;
div{
width: 300px;
height: 300px;
background-color: pink;
animation-name:fromLeftToRight;
animation-duration:2s;
animation-iteration-count:3;
}
@keyframes fromLeftToRight{
from{
margin-left: 10px;
}
to{
margin-left: 300px;
}
}
animation-direction:normal | reverse | alternate | alternate-reverse;
normal:正常方向
reverse:反方向運行
alternate:動畫先正常運行再反方向運行,並持續交替運行
alternate-reverse:動畫先反運行再正方向運行,並持續交替運行
div {
width: 100px;
height: 100px;
background: #5CBE3E;
margin: 5px;
animation-name: fromLeftToRight;
animation-duration: 3s;
animation-iteration-count: infinite;
}
div{
animation-direction: reverse;
}
.alternate {
animation-direction: alternate;
}
div {
animation-direction: alternate-reverse;
}
@keyframes fromLeftToRight {
from {
margin-left: 0;
}
to {
margin-left: 300px;
}
}
CSS之animation