연속되는 이미지를 연결해서 자연스럽게 움직이는 것처럼 보이게 만드는 기법
transition 속성 활용
animation 속성과 keyframe 활용
/* keyframe 작성 방법 */
@keyframes 애니메이션이름1 {
from {
left : 0;
}
to{
left : 200px;
}
}
@keyframes 애니메이션이름2 {
0% {
left : 0;
}
50%{
left : 200px;
}
100%{
top : 200px;
left : 200px;
}
}
/*어떠한 keyframes를 요소에 적용할 것인지 지정할 때 사용*/
animation-name: moveRight
/*애니메이션을 한 번 재생하는 데 걸리는 시간 설정*/
animation-duration: 2s
애니메이션 재생 방향 정의 (정방향 / 역방향)
/*정방향*/
animation-direction: normal
/*역방향*/
animation-direction: reverse
/*정방향-역방향 번갈아 재생*/
animation-direction: alternate
/*역방향-정방향번갈아 재생*/
animation-direction: alternate-reverse
/*애니메이션 재생 횟수 설정*/
animation-iteration-count: infinite
animation-iteration-count: 3
애니메이션 재생 패턴을 설정
transition-timing-function과 유사함
animation-timing-function: linear /*동일한 속도로 이벤트 진행*/
animation-timing-function: ease-in /*처음엔 느리게 시작, 마지막엔 빠르게 진행*/
animation-timing-function: ease-out /*처음엔 빠르게 시작, 마지막은 느리게 진행*/
animation-timing-function: ease
/*처음엔 천천히 시작, 중간에 빨라지고, 마지막엔 느리게 진행*/
/*ease-in-out과 동일한 형태지만 보다 가파르게 진행*/
animation-timing-function: ease-in-out
/*처음엔 천천히 시작, 중간에 빨라지고, 마지막엔 느리게 진행*/
/*ease와 동일한 형태지만 보다 완만하게 진행*/
애니메이션 시작의 지연시간 설정
animation-delay : 2s
애니메이션 카테고리에 속한 속성들도 단축 속성으로 모아서 지정 가능
단축 속성을 사용할 땐 순서에 유의
/*animation: name duration timing-function delay iteration-count
dirction*/
animation: moveRight 0.4s linear 1s infinite alternate