๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์นดํ…Œ๊ณ ๋ฆฌ ์—†์Œ

๋…ธ๋งˆ๋“œ์ฝ”๋” ์ฝ”์ฝ”์•„ํ†ก ํด๋ก ์ฝ”๋”ฉ 5์ผ์ฐจ

#4.0 - 4.1Transitions

4์žฅ์—์„œ๋Š” ๊ณ ๊ธ‰ CSS๋ฅผ ๋ฐฐ์šธ ๊ฒƒ์ด๋‹ค. animation, transition, transformation ๋“ฑ

 

Transition : ์–ด๋–ค ์ƒํƒœ์—์„œ ๋‹ค๋ฅธ ์ƒํƒœ๋กœ์˜ "๋ณ€ํ™”"๋ฅผ ์• ๋‹ˆ๋ฉ”์ด์…˜์œผ๋กœ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•

* transition ์†์„ฑ์€ state๊ฐ€ ์—†๋Š” ์š”์†Œ์— ๋ถ™์—ฌ์•ผ ํ•œ๋‹ค. → ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ฃผ๊ณ  ์‹ถ์€ ์š”์†Œ๊ฐ€ state์— ์žˆ์–ด์•ผ ๋ณ€ํ™”๊ฐ€ ์ƒ๊ธด๋‹ค.

<style>
	a {
    	color: wheat;
        background-color: tomato;
        border-radius: 5px;
        transition: all 5s eas-in-out;
        }
	a:hover {
    	color: tomato;
        background-color: wheat;
        }
</style>

 

ease-in function : ๋ธŒ๋ผ์šฐ์ €์—๊ฒŒ ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ์–ด๋–ป๊ฒŒ ๋ณ€ํ™”ํ•˜๋Š”์ง€ ๋งํ•ด์ฃผ๋Š” ๊ฒƒ

- linear : ์‹œ์ž‘๋ถ€ํ„ฐ ๋๊นŒ์ง€ ์ผ์ •ํ•œ ์†๋„

- ease-in : ์‹œ์ž‘๊ณผ ๋์ด ๋น ๋ฆ„

- ease-out : ์‹œ์ž‘๊ณผ ๋์ด ๋Š๋ฆผ

- ease-in-out : ์‹œ์ž‘์ด ๋น ๋ฅด๊ณ  ๋์ด ๋Š๋ฆผ

 

<ease-in function ํšจ๊ณผ ์‚ฌ์ดํŠธ โ–ฝ >

https://matthewlein.com/tools/ceaser

 

Ceaser - CSS Easing Animation Tool - Matthew Lein

Choose an easing type and test it out with a few effects. If you don’t quite like the easing, grab a handle and fix it. When you’re happy, snag your code and off you go. Now that we can use CSS transitions in all the modern browsers, let’s make them

matthewlein.com

 

 

* all : ๋ณ€ํ™” ์š”์†Œ๋ฅผ ํ•œ ๋ฒˆ์— ๋‹ค๋ฃธ.

>>๊ฐ๊ฐ ๋”ฐ๋กœ ๋‹ค๋ฃจ๊ณ  ์‹ถ์œผ๋ฉด ์ฝค๋งˆ(,)๋ฅผ ์จ์„œ ์—ฌ๋Ÿฌ transition์„ ์ค„ ์ˆ˜ ์žˆ๋‹ค.

 

 

#4.2 Transformations

Transformation: ๋ง ๊ทธ๋Œ€๋กœ ํ•œ ์š”์†Œ๋ฅผ ๋ณ€ํ˜•(transform)์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค.

 

**border-radius: 50% → ์›์ด ๋œ๋‹ค.!!

 

์˜ˆ) transform: rotateX(n deg) → X์ถ•์œผ๋กœ n๋„ ํšŒ์ „ (+Y / Z)

      transform: sclaeX(n deg) → X์ถ• ๊ธฐ์ค€์œผ๋กœ ํฌ๊ธฐ ๋ณ€๊ฒฝ

 

- transform์€ box element๋ฅผ ๋ณ€ํ˜•์‹œํ‚ค์ง€ ์•Š๋Š”๋‹ค. ์ฆ‰, ๋‹ค๋ฅธ ํ˜•์ œ ์š”์†Œ๋“ค์— ์˜ํ–ฅ์„ ๋ผ์น˜์ง€ ์•Š๋Š”๋‹ค.

- margin, padding์ด ์ ์šฉ๋˜์ง€ ์•Š๋Š”๋‹ค. ์ผ์ข…์˜ 3D์ด๊ธฐ ๋•Œ๋ฌธ

- transform๊ณผ transition์„ ์กฐํ•ฉํ•˜์—ฌ ๋” ๋ฉ‹์ง„ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค.

<style>
      img {
        border: 5px solid black;
        border-radius: 50%;
        transition: transform 2s ease-in-out;
      }
      img:hover {
        transform: rotate(360deg) scale(1.5);
      }
</style>

 

 

#4.3 - 4.4 Animations

๋งˆ์šฐ์Šค๋ฅผ ์˜ฌ๋ฆฌ๊ฑฐ๋‚˜, transition ์—†์ด ๊ณ„์† ์žฌ์ƒ๋˜๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ?

 

@keyframes ์• ๋‹ˆ๋ฉ”์ด์…˜์ด๋ฆ„ {
   <!--์–ด๋””์—์„œ๋ถ€ํ„ฐ ์–ด๋””๊นŒ์ง€ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ ์šฉํ• ์ง€-->
   from { }  
   to { }
}

<style>
      @keyframes thisisAnimation {
        from {
          transform: rotate(0deg);
        }
        to {
          transform: rotate(360deg);
        }
      }

      img {
        border: 5px solid black;
        border-radius: 50%;
        animation: thisisAnimation 5s ease-in-out;
      }
</style>

 

* animation: ... ๋์— infinite๋ฅผ ์“ฐ๋ฉด ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ฌดํ•œ ๋ฐ˜๋ณต.

 

๋˜๋Š”

@keyframes ์• ๋‹ˆ๋ฉ”์ด์…˜์ด๋ฆ„ {
   0% { }  
   50% { }

   100% { }
}

์ด์ฒ˜๋Ÿผ from to ๋ง๊ณ  1,2,3,4,5...10 ํ˜น์€ 0%, 25%, 50%, 75%, 100% ๊ฐ™์ด ์—ฌ๋Ÿฌ ๋‹จ๊ณ„๋กœ ๋‚˜๋ˆ„์–ด ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค.

→ ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ๋๋‚˜๋ฉด ๋‹ค์‹œ ์ฒ˜์Œ์œผ๋กœ ๋Œ์•„๊ฐ€์ง€ ์•Š๊ณ , ๊ณ„์† ์ด์–ด์ง€๋„๋ก ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค.

 

 

#4.5 Media Queries

media query : ์˜ค์ง CSS๋งŒ์„ ์ด์šฉํ•ด์„œ ์Šคํฌ๋ฆฐ์˜ ์‚ฌ์ด์ฆˆ๋ฅผ ์•Œ ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•

 

@media screen and (max-width: n px) { }

 

min ์‚ฌ์ด์ฆˆ์™€ max ์‚ฌ์ด์ฆˆ๋ฅผ ์กฐ์ ˆํ•˜์—ฌ ์Šคํฌ๋ฆฐ ์‚ฌ์ด์ฆˆ์— ๋”ฐ๋ผ ์Šคํƒ€์ผ์˜ ๋ณ€ํ™”๋ฅผ ์ค„ ์ˆ˜ ์žˆ๋‹ค.

 <style>
      @media screen and (max-width: 600px) {
        div {
          background-color: violet;
        }
      }
      @media screen and (min-width: 601px) and (max-width: 1200px) {
        div {
          background-color: wheat;
        }
      }
      @media screen and (min-width: 1200px) {
        div {
          background-color: hotpink;
        }
      }
</style>

 

 

@media screen์— (orientation: landscape | portrait) ์„ ์ถ”๊ฐ€ํ•˜๋ฉด ํ•ธ๋“œํฐ์ด ๊ฐ€๋กœ๋ชจ๋“œ์ธ์ง€ ์„ธ๋กœ๋ชจ๋“œ์ธ์ง€ ๊ตฌ๋ณ„ํ•  ์ˆ˜ ์žˆ๋‹ค.

*landscape = ๊ฐ€๋กœ, protrait = ์„ธ๋กœ

 

 

#4.6 Media Queries Recap

  • media query ์•ˆ์— ์›ํ•˜๋Š” ๋ชจ๋“  CSS๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค.
  • media query๋Š” and๋ฅผ ์จ์„œ ์—ฐ๊ฒฐ๋œ๋‹ค.
  • "min-width"๋Š” ์ปดํ“จํ„ฐ, ํ•ธ๋“œํฐ ๋ชจ๋‘ ์ ์šฉ๋˜์ง€๋งŒ "min-device-width"๋Š” ์˜ค์ง ํ•ธ๋“œํฐ์—๋งŒ ์ ์šฉ๋œ๋‹ค.
  • @media print๋ฅผ ์ด์šฉํ•˜๋ฉด ๋ธŒ๋ผ์šฐ์ € ์ธ์‡„ ํŽ˜์ด์ง€์—์„œ์˜ ์†์„ฑ์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋‹ค.