🔥 transition 효과
🔥 animation 효과
🔥 transform 효과
✍🏻 html
<!DOCTYPE html> <html lang="en"> <head> <title>The time</title> <style> a { color: white; background-color: tomato; text-decoration: none; padding: 3px 5px; border-radius: 5px; font-size: 55px; transition: all 1s ease-in-out; } a:hover { border-radius: 30px; color: tomato; background-color: wheat; padding-right: 200px; } </style> </head> <body> <a href="#">Go home</a> </body> </html>
1) animation 사용법
- @keyframes 스타일 : 시작(0% 또는 from), 마지막(100% 또는 to), 중간에 여러 구간을 나눌 수 있음
- animation 설정
- animation-name : keyframes 이름 넣기
- animation-duration : 애니메이션 작동 시간 지정
- animation-timing-function : 속도에 따른 움직임 스타일 지정
- animation-iteration-count : 반복 횟수 지정(디폴트는 1이며, infinite는 무한 반복)
- animation-delay : 얼마나 대기하였다가 작동하는지 설정
- anaimation-fill-mode
- none : 처음스타일 ⇢ 0% ⇢ 100% ⇢ 처음 스타일
- forwards : 처음스타일 ⇢ 0% ⇢ 100% ⇢ 100%
- backwards : 0% ⇢ 0% ⇢ ⇢ 100% ⇢ 처음 스타일
- both : 0% ⇢ 0% ⇢ ⇢ 100% ⇢ 100%
- anaimation-play-state
- paused : 중지상태
- running : 실행 상태(default 값)
✍🏻 html
<!DOCTYPE html> <html lang="en"> <head> <title>The time</title> <style> @keyframes rotateX_animation { 0% { transform: rotateX(0); } 25% { transform: rotateX(120deg); } 50% { transform: rotateX(240deg); } 50% { transform: rotateX(360deg); } } .rotateX { width: 200px; height: 200px; background-color: mediumspringgreen; border: 3px solid; border-radius: 50%; animation: rotateX_animation 10s linear; } @keyframes rotateY_animation { from { transform: rotateY(0); } to { transform: rotateY(360deg); } } .rotateY { width: 200px; height: 200px; background-color: tomato; border: 3px solid; border-radius: 50%; animation: rotateY_animation 5s ease-in-out infinite; } </style> </head> <body> <div class="rotateX"></div> <div class="rotateY"></div> </body> </html>
1) tranform 사용법
- selector:state { transform : 함수;}
- transform의 함수는 3차원 공간에서 x,y,z 요소로 설정함
- 🔍 selector:state { transform : translate(x,y) } : 요소 위치를 가로로 x, 세로로 y만큼 이동
- 🔍 selector:state { transform : translateX(n) } : 요소 위치를 가로로 x만큼 이동
- 🔍 selector:state { transform : translateY(n) } : 요소 위치를 세로로 Y만큼 이동
- 🔍 selector:state { transform : sacle(x,y) } : 요소 크기를 가로로 x배, 세로로 y배 확대 또는 축소
- 🔍 selector:state { transform : sacleX(n) } : 요소 크기를 가로로 x배 확대 또는 축소
- 🔍 selector:state { transform : sacleY(n) } : 요소 크기를 세로로 y배 확대 또는 축소
- 🔍 selector:state { transform : skew(x,y) } : 요소를 가로로 x도, 세로로 y도 만큼 기울임
- 🔍 selector:state { transform : skewX(n) } : 요소를 가로로 x도 만큼 기울임
- 🔍 selector:state { transform : skewY(n) } : 요소를 세로로 y도 만큼 기울임또는 축소
- 🔍 selector:state { transform : rotate(n) } : 요소를 주어진 각도 만큼 회전
✍🏻 html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <style> .box { width: 200px; height: 200px; margin: 20px; border: 1px solid; text-align: center; font-size: 20px; border-radius: 15px; } .box1 { background-color: cornflowerblue; } .box2 { background-color: coral; } .box3 { background-color: papayawhip; } .box4 { background-color: darkseagreen; } .translate:hover { transition: transform 2s; transform: translate(30px, 30px); } .scale:hover { transition: transform 2s; transform: scale(2, 2); } .skew:hover { transition: transform 2s; transform: skew(30deg, 30deg); } .rotate:hover { transition: transform 2s; transform: rotate(360deg); } </style> </head> <body> <div class="box box1 translate">translate</div> <div class="box box2 scale">scale</div> <div class="box box3 skew">skew</div> <div class="box box4 rotate">rotate</div> </body> </html>