Search
Duplicate
๐Ÿ•บ

CSS animaion์—์„œ์˜ key frame

๊ฐ„๋‹จ์†Œ๊ฐœ
keyframe์ด ์ด๋Ÿฐ๊ฑฐ๊ตฌ๋‚˜~
ํŒ”๋งŒ์ฝ”๋”ฉ๊ฒฝ ์ปจํŠธ๋ฆฌ๋ทฐํ„ฐ
ContributorNotionAccount
์ฃผ์ œ / ๋ถ„๋ฅ˜
CSS
Scrap
ํƒœ๊ทธ
9 more properties
[ index ]
1.ย @keyframesย ์™€ย ์• ๋‹ˆ๋ฉ”์ด์…˜ย ์†Œ๊ฐœ
2.ย @keyframes
3. animation
4.ย Vendorย Prefixesย ๋”ํ•˜๊ธฐ

1. @keyframes ์™€ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์†Œ๊ฐœ

๋™์˜์ƒ ์‘์šฉ์—์„œ ์‚ฌ์šฉํ•˜๋Š” ์–ธ์–ด๋กœ, ์‹œ์ž‘ ํ”„๋ ˆ์ž„๊ณผ ๋งˆ์ง€๋ง‰ ํ”„๋ ˆ์ž„ ์ค‘์—์„œย ์ „์ฒด ์ •๋ณด๋ฅผ ๊ฐ–๊ณ  ์žˆ์–ด์„œ ๊ฐ€์žฅ ์ค‘์‹ฌ์ด ๋˜๋Š” ํ”„๋ ˆ์ž„์„ ํ‚ค ํ”„๋ ˆ์ž„ ์ด๋ผ๊ณ  ํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์• ๋‹ˆ๋ฉ”์ด์…˜์—์„œ๋Š” ์ฒ˜์Œ ํ™”๋ฉด์€ ์ „์ฒด ์ •๋ณด๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์œผ๋‚˜ ๋’ค์˜ ํ™”๋ฉด๋“ค์€ ์ „์ฒด ์ •๋ณด๋ฅผ ๋ชจ๋‘ ๊ฐ–๊ณ  ์žˆ์„ ํ•„์š”๊ฐ€ ์—†๋‹ค. ์™œ๋ƒํ•˜๋ฉด ์•ž์˜ ์ „์ฒด ์ •๋ณด๋ฅผ ๊ฐ–๊ณ  ์žˆ๋Š” ํ™”๋ฉด๊ณผ ๋น„๊ตํ•ด์„œ ์ฐจ์ด๊ฐ€ ์žˆ๋Š” ์ •๋ณด๋งŒ ๋‹ด์œผ๋ฉด ๋˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ์ด๋•Œ ์ „์ฒด ์ •๋ณด๋ฅผ ๋‹ด๊ณ  ์žˆ๋Š” ๊ฒƒ์ด ํ‚ค ํ”„๋ ˆ์ž„์ด๋‹ค. ์ด๋ ‡๊ฒŒ ํ‚ค ํ”„๋ ˆ์ž„์„ ์ง€์ •ํ•˜๋ฉด ์ „์ฒด์ ์œผ๋กœ ์šฉ๋Ÿ‰์„ ์ค„์ผ ์ˆ˜ ์žˆ๋‹ค. ์• ๋‹ˆ๋ฉ”์ด์…˜์—์„œ๋Š” ์ฒ˜์Œ ํ™”๋ฉด์„ ํ‚ค ํ”„๋ ˆ์ž„์œผ๋กœ ์ง€์ •ํ•œ ํ›„์—๋„ ๊ฐ ์ฃผ๊ธฐ๋งˆ๋‹ค ์ „์ฒด ์ •๋ณด๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ํ‚ค ํ”„๋ ˆ์ž„์„ ๋งŒ๋“ค์–ด ๋„ฃ์Œ์œผ๋กœ์จ ํ™”๋ฉด์ด ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์ด์–ด์ง€๋„๋ก ํ•œ๋‹ค.
์‚ฌ์ด์–ธ์Šค์˜ฌ์— ๋”ฐ๋ฅด๋ฉด key-frame์ด๋ž€ animation์˜ ์‹œ์ž‘๊ณผ ์ค‘๊ฐ„, ๋์˜ ์ •๋ณด๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ํ‹€์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. CSS ์• ๋‹ˆ๋ฉ”์ด์…˜์—์„œ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ์š”์†Œ๊ฐ€ ๋ฐ”๋กœย @keyframesย ์ž…๋‹ˆ๋‹ค. @keyframes๋Š” CSS ๋ฌธ๋ฒ• ์ค‘ ํ•˜๋‚˜๋กœ ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ๋งŒ๋“ค์–ด์ง€๋Š” ๋ถ€๋ถ„์ž…๋‹ˆ๋‹ค.ย @keyframesย ์•ˆ์—์„œ ์šฐ๋ฆฌ๋Š” ์Šคํ…Œ์ด์ง€๋“ค์„ ์ •์˜ํ•˜๊ณ  ๊ฐ ๊ตฌ๊ฐ„๋งˆ๋‹ค ๋‹ค๋ฅธ ์Šคํƒ€์ผ์„ ์ ์šฉ ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

2. @keyframes

์—ฌ๊ธฐ์„œ ์šฐ๋ฆฌ๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜ ์Šคํ…Œ์ด์ง€๋“ค์„ ์ •ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์šฐ๋ฆฌ์˜ย @keyframesย ์†์„ฑ์€:
โ€ข
์šฐ๋ฆฌ๊ฐ€ ์ •ํ•œ ์ด๋ฆ„ (์—ฌ๊ธฐ์„œ๋Š”ย tutsFade๋กœ ์ •ํ–ˆ์Šต๋‹ˆ๋‹ค)
โ€ข
์Šคํ…Œ์ด์ง€: 0%-100%, from (0%์™€ ๊ฐ™์Œ) ๊ทธ๋ฆฌ๊ณ  to (100%์™€ ๊ฐ™์Œ)
โ€ข
CSS ์Šคํƒ€์ผ: ๊ฐ ๊ตฌ๊ฐ„์— ์ ์šฉ์‹œํ‚ฌ ์Šคํƒ€์ผ
์˜ˆ๋ฅผ ๋“ค์–ด:
@keyframes tutsFade { 0% { opacity: 1; } 100% { opacity: 0; } }
CSS
๋ณต์‚ฌ
ํ˜น์€:
@keyframes tutsFade { from { opacity: 1; } to { opacity: 0; } }
CSS
๋ณต์‚ฌ
๋˜๋Š” ์ค„์—ฌ์„œ ์“ธ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
@keyframes tutsFade { to { opacity: 0; } }
CSS
๋ณต์‚ฌ
์ƒ๋‹จ์˜ ์ฝ”๋“œ๋Š” ์—˜๋ ˆ๋ฉ˜ํŠธ์˜ ํˆฌ๋ช…๋„๋ฅผย opacity: 1์—์„œย opacity: 2๋กœ ๋ณ€ํ•˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค. ์œ„์˜ ์„ธ๊ฐ€์ง€ ๋ฐฉ๋ฒ• ๋ชจ๋‘ ๋™์ผํ•œ ๊ฒฐ๊ณผ๋กœ ๋‚˜์˜ต๋‹ˆ๋‹ค.

3. Animation

animationย ์†์„ฑ์€ ์˜ˆ์ „์—ย @keyframes๋กœ ๋ถˆ๋ฆฌ๋ฉฐ CSS ์„ ํƒ์ž ์•ˆ์—์„œ ์กด์žฌํ–ˆ์—ˆ์Šต๋‹ˆ๋‹ค. ์• ๋‹ˆ๋ฉ”์ด์…˜์€ ์—ฌ๋Ÿฌ๊ฐœ์˜ ์†์„ฑ์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
โ€ข
animation-name:ย @keyframesย ์ด๋ฆ„ (์˜ˆ์‹œ์—์„œ๋Š”ย tutsFade๋ฅผ ์‚ฌ์šฉํ•จ)
โ€ข
animation-duration: ํƒ€์ž„ํ”„๋ ˆ์ž„ ๊ธธ์ด. ์• ๋‹ˆ๋ฉ”์ด์…˜ ์‹œ์ž‘๋ถ€ํ„ฐ ๋งˆ์ง€๋ง‰๊นŒ์ง€ ์ด ์ง€์†์‹œ๊ฐ„
โ€ข
animation-timing-function:ย ์• ๋‹ˆ๋ฉ”์ด์…˜ ์†๋„ ์กฐ์ ˆ (ย linear | ease | ease-in | ease-out | ease-in-out | cubic-bezierย ).
โ€ข
animation-delay: ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ์‹œ์ž‘ํ•˜๊ธฐ ์ „ ์ง€์—ฐ์‹œ๊ฐ„
โ€ข
animation-iteration-count: ๋ฐ˜๋ณต ํšŸ์ˆ˜
โ€ข
animation-direction: ๋ฃจํ”„ (loop) ๋ฐฉํ–ฅ. ์ •๋ฐฉํ–ฅ์œผ๋กœ ๋ฐ˜๋ณต, ์—ญ๋ฐฉํ–ฅ์œผ๋กœ ๋ฐ˜๋ณต, ๋ฒˆ๊ฐˆ์•„๊ฐ€๋ฉฐ ๋ฐ˜๋ณต ๋“ฑ์„ ์„ค์ •
โ€ข
animation-fill-mode: ์• ๋‹ˆ๋ฉ”์ด์…˜ ์‹œ์ž‘/๋ ์ƒํƒœ ์ œ์–ด (ย none | forwards | backwards | bothย )
์˜ˆ๋ฅผ ๋“ค์–ด:
.element { animation-name: tutsFade; animation-duration: 4s; animation-delay: 1s; animation-iteration-count: infinite; animation-timing-function: linear; animation-direction: alternate; }
CSS
๋ณต์‚ฌ
ํ˜น์€ ์งง๊ฒŒ:
.element { animation: tutsFade 4s 1s infinite linear alternate; } @keyframes tutsFade { from { opacity: 1; } to { opacity: 0; } }
CSS
๋ณต์‚ฌ
์ƒ๋‹จ์˜ ์ฝ”๋“œ๋Š”ย 1์ดˆ์˜ ์ง€์—ฐ์‹œ๊ฐ„ ํ›„ 4์ดˆ์˜ ์ด ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ธธ์ด๋ฅผ ๊ฐ€์ง€๊ณ  loop ๋ฐฉํ–ฅ์„ ๋ฒˆ๊ฐˆ์•„๊ฐ€๋ฉด์„œ ์„ ํ˜• ์†๋„๋กœ ๋ฌดํ•œ ๋ฐ˜๋ณต ๊นœ๋นก๊ฑฐ๋ฆฌ๋Š” ํšจ๊ณผ๋ฅผ ๋งŒ๋“ค ๊ฒƒ์ž…๋‹ˆ๋‹ค.
๋” ๋งŽ์€ ํšจ๊ณผ๋Š” ์•„๋ž˜์˜ ์‚ฌ์ดํŠธ๋ฅผ ์ฐธ๊ณ ํ•ฉ๋‹ˆ๋‹ค!

4. Vendor Prefixes ๋”ํ•˜๊ธฐ

์ž‘์—… ์ดˆ์•ˆ์„ ๋งŒ๋“œ๋Š”๋™์•ˆ, ์šฐ๋ฆฌ๋Š” ๋ธŒ๋ผ์šฐ์ €์— ๋งž๋Š” ํ”„๋ฆฌํ”ฝ์Šค๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ธŒ๋ผ์šฐ์ € ์ง€์›์ด ๊ฐ€๋Šฅํ•œ ์ž˜๋˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. ๊ธฐ๋ณธ ํ”„๋ฆฌํ”ฝ์Šค๋“ค์„ ๋‹ฌ์•„์ค๋‹ˆ๋‹ค:
โ€ข
ํฌ๋กฌ & ์‚ฌํŒŒ๋ฆฌ:ย webkit-
โ€ข
ํŒŒ์ด์–ดํญ์Šค:ย moz-
โ€ข
์˜คํŽ˜๋ผ:ย o-
โ€ข
์ธํ„ฐ๋„ท ์ต์Šคํ”Œ๋กœ๋Ÿฌ:ย ms-
animationย ์†์„ฑ์„ ๋ฒค๋” ํ”„๋ฆฌํ”ฝ์Šค์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋ฉด ์ด๋ ‡๊ฒŒ ๋ฉ๋‹ˆ๋‹ค:
.element { -webkit-animation: tutsFade 4s 1s infinite linear alternate; -moz-animation: tutsFade 4s 1s infinite linear alternate; -ms-animation: tutsFade 4s 1s infinite linear alternate; -o-animation: tutsFade 4s 1s infinite linear alternate; animation: tutsFade 4s 1s infinite linear alternate; }
CSS
๋ณต์‚ฌ
@keyframesย ์˜†์—๋„ ๋ถ™์—ฌ ์ค๋‹ˆ๋‹ค:
@-webkit-keyframes tutsFade {/* your style */ } @-moz-keyframes tutsFade {/* your style */ } @-ms-keyframes tutsFade {/* your style */ } @-o-keyframes tutsFade {/* your style */ } @keyframes tutsFade {/* your style */ }
CSS
๋ณต์‚ฌ
๋งˆ์ง€๋ง‰ ๊ฒฐ๊ณผ๋ฌผ์—์„œ๋Š” ํ”„๋ฆฌํ”ฝ์Šค๋ฅผ ํฌํ•จํ•˜๊ณ  ์—ฌ๋Ÿฌ๋ถ„๋„ CSS ์ฝ”๋“œ์— ํ”„๋ฆฌํ”ฝ์Šค๋ฅผ ๋„ฃ๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•ฉ๋‹ˆ๋‹ค.
<์ถœ์ฒ˜>
CSS ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ดˆ๋ณด์ž ์ž…๋ฌธ์„œ (https://webdesign.tutsplus.com/ko/tutorials/a-beginners-introduction-to-css-animation--cms-21068)