Transition

1. ๊ฐœ์š”

ํŠธ๋žœ์ง€์…˜(transition)์€ CSS ํ”„๋กœํผํ‹ฐ์˜ ๊ฐ’์ด ๋ณ€ํ™”ํ•  ๋•Œ, ํ”„๋กœํผํ‹ฐ ๊ฐ’์˜ ๋ณ€ํ™”๊ฐ€ ์ผ์ • ์‹œ๊ฐ„(durationi)์— ๊ฑธ์ณ ์ผ์–ด๋‚˜๋„๋ก ํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์›น ์š”์†Œ์˜ ๋ฐฐ๊ฒฝ์ƒ‰์„ ๋ฐ”๊พธ๊ฑฐ๋‚˜ ๋„ํ˜•์˜ ํ…Œ๋‘๋ฆฌ๋ฅผ ์‚ฌ๊ฐํ˜•์—์„œ ์›ํ˜•์œผ๋กœ ๋ฐ”๊พธ๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ์Šคํƒ€์ผ ์†์„ฑ์ด ๋ฐ”๋€Œ๋Š” ๊ฒƒ์„ ๋งํ•œ๋‹ค.

transition์˜ ํ”„๋กœํผํ‹ฐ๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

ํ”„๋กœํผํ‹ฐ
์„ค๋ช…
๊ธฐ๋ณธ๊ฐ’

transition-property

ํŠธ๋žœ์ง€์…˜์˜ ๋Œ€์ƒ์ด ๋˜๋Š” CSS ํ”„๋กœํผํ‹ฐ๋ฅผ ์ง€์ •ํ•œ๋‹ค.

all

transition-duration

ํŠธ๋žœ์ง€์…˜์ด ์ผ์–ด๋‚˜๋Š” ์ง€์†์‹œ๊ฐ„์„ ์ดˆ ๋‹จ์œ„ ๋˜๋Š” ๋ฐ€๋ฆฌ ์ดˆ ๋‹จ์œ„๋กœ ์ง€์ •ํ•œ๋‹ค.

0s

transition-timing-function

ํŠธ๋ž˜๋‹ž์…˜ ํšจ๊ณผ๋ฅผ ์œ„ํ•œ ์ˆ˜์น˜ ํ•จ์ˆ˜๋ฅผ ์ง€์ •ํ•œ๋‹ค.

ease

transition-delay

ํ”„๋กœํผํ‹ฐ๊ฐ€ ๋ณ€ํ™”ํ•œ ์‹œ์ ๊ณผ ํŠธ๋žœ์ง€์…˜์ด ์‹ค์ œ๋กœ ์‹œ์ž‘ํ•˜๋Š” ์‚ฌ์ด์— ๋Œ€๊ธฐํ•˜๋Š” ์‹œ๊ฐ„์„ ์ดˆ ๋‹จ์œ„ ๋˜๋Š” ๋ฐ€๋ฆฌ ์ดˆ ๋‹จ์œ„๋กœ ์ง€์ •ํ•œ๋‹ค.

0s

transition

๋ชจ๋“  ํŠธ๋žœ์ง€์…˜ ํ”„๋กœํผํ‹ฐ๋ฅผ ํ•œ๋ฒˆ์— ์ง€์ •ํ•œ๋‹ค.(shorthand syntax)


2. transition-property

ํŠธ๋žœ์ง€์…˜์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ๋Š” transition-property ์†์„ฑ์„ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค. ํ•ด๋‹น ์†์„ฑ์„ ์‚ฌ์šฉํ•จ์œผ๋กœ์จ ํŠธ๋žœ์ง€์…˜์˜ ๋Œ€์ƒ์ด ๋˜๋Š” CSS ํ”„๋กœํผํ‹ฐ๋ช…์„ ์ง€์ •ํ•œ๋‹ค. ๋ณต์ˆ˜์˜ ํ”„๋กœํผํ‹ฐ๋ฅผ ์ง€์ •ํ•˜๋Š” ๊ฒฝ์šฐ ์‰ผํ‘œ(,)๋กœ ๊ตฌ๋ถ„ํ•œ๋‹ค.

๊ธฐ๋ณธํ˜• transition-property: all || none || <์†์„ฑ์ด๋ฆ„>

๋ชจ๋“  CSS ํ”„๋กœํผํ‹ฐ๊ฐ€ ํŠธ๋žœ์ง€์…˜์˜ ๋Œ€์ƒ์ด ๋  ์ˆ˜ ์—†๋‹ค. ์•„๋ž˜๋Š” ํŠธ๋žœ์ง€์…˜์ด ๋Œ€์ƒ์ด ๋  ์ˆ˜ ์žˆ๋Š” CSS ํ”„๋กœํผํ‹ฐ์ด๋‹ค.

๊ตฌ๋ถ„
ํ”„๋กœํผํ‹ฐ

Box model

width, height, max-width, max-height, min-width, min-height, padding, margin, border-color, border-width, border-spacing

Background

background-color, background-position

์ขŒํ‘œ

top, left, right, bottom

ํ…์ŠคํŠธ

color, font-size, font-weight, letter-spacing, line-height, text-indent, text-shadow, vertical-align, word-spacing

๊ธฐํƒ€

opacity, outline-color, outline-offset, outline-width, visibility, z-index


3. transition-duration

transition-duration ํ”„๋กœํผํ‹ฐ๋Š” ํŠธ๋žœ์ง€์…˜์— ์ผ์–ด๋‚˜๋Š” ์ง€์†์‹œ๊ฐ„์„ ์ดˆ ๋‹จ์œ„ ๋˜๋Š” ๋ฐ€๋ฆฌ ์ดˆ ๋‹จ์œ„๋กœ ์ง€์ •ํ•œ๋‹ค. ํ•ด๋‹น ํ”„๋กœํผํ‹ฐ๋ฅผ ํ†ตํ•ด ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋ฐ”๋€Œ๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜ ํšจ๊ณผ๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค. ํ”„๋กœํผํ‹ฐ๊ฐ’์„ ์ง€์ •ํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ ๊ธฐ๋ณธ๊ฐ’ 0s์ด ์ ์šฉ๋˜์–ด ์–ด๋– ํ•œ ํŠธ๋žœ์ง€์…˜ ํšจ๊ณผ๋„ ๋ณผ ์ˆ˜ ์—†๋‹ค.

๊ธฐ๋ณธํ˜• transition-duration: <์‹œ๊ฐ„>

<!DOCTYPE html>
<html>
  <head>
    <style>
      div {
        width: 120px;
        height: 120px;
        background-color: green;
        transition-property: width, height;
        transition-duration: 1s, 2s;
      }
      div:hover {
        width: 240px;
        height: 240px;
      }
    </style>
  </head>
  <body>
    <div></div>
  </body>
</html>

์œ„์˜ ์ฝ”๋“œ์˜ ๊ฒฝ์šฐ div box์— ๋งˆ์šฐ์Šค๋ฅผ ์˜ฌ๋ฆฌ๊ฒŒ ๋˜๋ฉด ๊ฐ€๋กœ์˜ ๊ธธ์ด๋Š” 1์ดˆ ๋™์•ˆ ์ด 120px๋งŒํผ ๋Š˜์–ด๋‚˜๊ฒŒ ๋˜๊ณ  ๋†’์ด๋Š” 2์ดˆ ๋™์•ˆ 120px๋งŒํผ ๋Š˜์–ด๋‚˜๊ฒŒ ๋œ๋‹ค.


4. transition-timing-function

ํ•ด๋‹น ์†์„ฑ์€ ํŠธ๋ž˜์ง€์…˜ ํšจ๊ณผ์˜ ๋ณ€ํ™” ํ๋ฆ„, ์‹œ๊ฐ„์— ๋”ฐ๋ฅธ ๋ณ€ํ™” ์†๋„์™€ ๊ฐ™์€ ์ผ์ข…์˜ ๋ณ€ํ™”์˜ ๋ฆฌ๋“ฌ์„ ์ง€์ •ํ•œ๋‹ค. ํŠธ๋žœ์ง€์…˜ ํšจ๊ณผ์˜ ์‹œ์ž‘, ์ค‘๊ฐ„, ๋์—์„œ ์†๋„๋ฅผ ์ง€์ •ํ•ด ์ „์ฒด ์†๋„ ๊ณก์„ ์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค. ์†๋„ ๊ณก์„œ์€ ๋ฏธ๋ฆฌ ์ •ํ•ด์ง„ ํ‚ค์›Œ๋“œ๋‚˜ ๋ฒ ์ง€์— ๊ณก์„ ์„ ์ด์šฉํ•ด ํ‘œํ˜„ํ•œ๋‹ค.

๊ธฐ๋ณธํ˜• transition-timing-function: linear || ease || ease-in || ease-out || ease-in-out || cubic-bezier(n, n, n, n)

์•„๋ž˜๋Š” transition-timing-function์˜ ํ”„๋กœํผํ‹ฐ ๊ฐ’๊ณผ ์„ค๋ช…์ด๋‹ค.

ํ”„๋กœํผํ‹ฐ ๊ฐ’
์„ค๋ช…

ease

๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ๋Š๋ฆฌ๊ฒŒ ์‹œ์ž‘ํ•˜์—ฌ ์ ์  ๋นจ๋ผ์กŒ๋‹ค๊ฐ€ ๋Š๋ฆฌ์ง€๋ฉด์„œ ์ข…๋ฃŒํ•œ๋‹ค.

linear

์‹œ์ž‘๋ถ€ํ„ฐ ์ข…๋ฃŒ๊นŒ์ง€ ๋“ฑ์† ์šด๋™์„ ํ•œ๋‹ค.

ease-in

๋Š๋ฆฌ๊ฒŒ ์‹œ์ž‘ํ•œ ํ›„ ์ผ์ •ํ•œ ์†๋„์— ๋‹ค๋‹ค๋ฅด๋ฉด ๊ทธ ์ƒํƒœ๋กœ ๋“ฑ์† ์šด๋™ํ•œ๋‹ค.

ease-out

์ผ์ •ํ•œ ์†๋„์˜ ๋“ฑ์†์œผ๋กœ ์‹œ์ž‘ํ•ด์„œ ์ ์  ๋Š๋ ค์ง€๋ฉด์„œ ์ข…๋ฃŒํ•œ๋‹ค.

ease-in-out

๋Š๋ฆฌ๊ฒŒ ์‹œ์ž‘ํ•˜๊ณ  ๋Š๋ฆฌ๊ฒŒ ๋๋‚œ๋‹ค.

cubic-bezier(n, n, n, n)

๋ฒ ์ง€์— ํ•จ์ˆ˜๋ฅผ ์ •์˜ํ•ด์„œ ์‚ฌ์šฉํ•œ๋‹ค. ์ด๋•Œ n๊ฐ’์€ 0~1 ์‚ฌ์ด๋งŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.


5. transition-delay

transition-delay ํ”„๋กœํผํ‹ฐ๋Š” ํŠธ๋žœ์ง€์…˜ ํšจ๊ณผ๋ฅผ ์–ธ์ œ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•  ๊ฒƒ์ธ์ง€ ์„ค์ •ํ•œ๋‹ค. ์ฆ‰, transition-delay๋กœ ๋Œ€๊ธฐ ์‹œ๊ฐ„์„ ์ง€์ •ํ•˜์—ฌ ํ”„๋กœํผํ‹ฐ์˜ ๊ฐ’์ด ๋ณ€ํ™”ํ•˜์—ฌ๋„ ์ฆ‰์‹œ ํŠธ๋žœ์ง€์…˜์ด ์‹คํ–‰๋˜์ง€ ์•Š๊ณ , ์ผ์ • ์‹œ๊ฐ„ ๋Œ€๊ธฐํ•œ ํ›„ ํŠธ๋žœ์ง€์…˜์ด ์‹คํ–‰๋˜๋„๋ก ํ•œ๋‹ค. ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ฐ’์€ ์ดˆ(s)๋‚˜ ๋ฐ€๋ฆฌ์ดˆ(ms)์ด๋ฉฐ, ๊ธฐ๋ณธ๊ฐ’์€ 0์ด๋‹ค.

๊ธฐ๋ณธํ˜• transtition-delay: <์‹œ๊ฐ„>


6. transition

์œ„์—์„œ ์„ค๋ช…ํ•œ ๋ชจ๋“  ํŠธ๋žœ์ง€์…˜ ํ”„๋กœํผํ‹ฐ๋ฅผ ํ•œ๋ฒˆ์— ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋Š” shorthand์ด๋‹ค.

๊ธฐ๋ณธํ˜• transition: <transition-property๊ฐ’> || <transition-duration๊ฐ’ || <transition-timing-function๊ฐ’> || <transition-delay๊ฐ’>

๊ธฐ๋ณธ๊ฐ’ transition: all 0 ease 0

ํ”„๋กœํผํ‹ฐ๊ฐ’์„ ์ž‘์„ฑํ•˜๋Š” ์ˆœ์„œ๋Š” ์ƒ๊ด€์ด ์—†๋‹ค. ๋‹ค๋งŒ transition-duration์€ ๋ฐ˜๋“œ์‹œ ์ง€์ •ํ•ด์•ผ ํ•œ๋‹ค.


์ฐธ๊ณ 

poiemaweb 2-14 ํŠธ๋žœ์ง€์…˜ ๋„์„œ - HTML + CSS + ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์›น ํ‘œ์ค€์˜ ์ •์„


๐Ÿ‘†

๐Ÿ“… 2022-07-23

Last updated