day8

์ƒ์€๐Ÿ‘ธยท2023๋…„ 10์›” 17์ผ
1

๋šœ๋ฒ…๋šœ๋ฒ… ๋‘๋ฒˆ์งธ

๋ชฉ๋ก ๋ณด๊ธฐ
6/13
post-thumbnail
post-custom-banner

๐Ÿ“Œ์ •๋ฆฌ

relative = ํ๋ฆ„๋Œ€๋กœ // ์‹œ์ž‘์  : ๊ฐ์ž์œ„์น˜
absolute = ํ๋ฆ„๋ฌด์‹œ // ์‹œ์ž‘์  : ๋ถ€๋ชจ์š”์†Œ์œ„์น˜ ๋ถ€๋ชจ์š”์†Œ์ค‘์— relative๊ฐ€ ์žˆ์œผ๋ฉด ๊ทธ๊ฒŒ ์‹œ์ž‘์ ! relative ์—†์œผ๋ฉด body๊ฐ€ ์‹œ์ž‘์ !
fixed = ํ๋ฆ„๋ฌด์‹œ, ์Šคํฌ๋กค ๋‚ด๋ ค๋„ ๊ณ ์ •์œ„์น˜ // ์‹œ์ž‘์  : ๋ถ€๋ชจ์š”์†Œ ์ƒ๊ด€์—†์ด ๊ทธ๋ƒฅ ์ „์ฒดํŽ˜์ด์ง€ ๊ธฐ์ค€

=================================================
transition : ๋‹ค๋ฅธ ์†์„ฑ๋“ค์˜ ๋ณ€ํ™”, ์ผ์ •์‹œ๊ฐ„๋™์•ˆ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ // 1ํšŒ๋งŒ!!! // ๋งˆ์šฐ์Šค์˜ค๋ฒ„์—์„œ ๋งˆ์šฐ์Šค ๋—์„๋•Œ ๋‹ค์‹œ ์›๋ž˜๋Œ€๋กœ ๋Œ์•„์˜ค๋Š” (ํœ™๋Œ์•„์˜ค๋ƒ vs ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์Šค๋ฅด๋ฅต ๋Œ์•„์˜ค๋ƒ)

animation : ์—ฌ๋Ÿฌ๋‹จ๊ณ„๋กœ ๋‚˜๋ˆ ์„œ, ์›€์ง์ž„ // ๋ช‡ํšŒ๋ฐ˜๋ณต, ๋ฌด์ œํ•œ ๋ฐ˜๋ณต // ๋งˆ์šฐ์Šค์˜ค๋ฒ„์—์„œ ๋งˆ์šฐ์Šค๋ฅผ ๋–ผ๋ฉด ๋‹ค์‹œ ์›๋ž˜๋Œ€๋กœ ๋Œ์•„์˜ค์ง€ ์•Š๊ณ  ๊ทธ์ž๋ฆฌ์—์„œ ๋ฉˆ์ถค

transform : ํ•ด๋‹น ์š”์†Œ์˜ ํฌ๊ธฐ,ํšŒ์ „,์ด๋™

transition + transform
animation + transform

๐Ÿ’กํšจ๊ณผ๊ฐ€ ๋‚˜ํƒ€๋‚˜๊ฒŒ ํ•˜๊ณ  ์‹ถ์€ ๋ฐ•์Šค์— transition, animation ์†์„ฑ๋“ค ๋„ฃ๋Š”๊ฒƒ!!

=================================================

๐Ÿšจ๐Ÿšจ๐Ÿšจ์ฃผ์˜๐Ÿšจ๐Ÿšจ๐Ÿšจ
transition,animation์€ ์†์„ฑ ๋”ฐ๋กœ ์จ๋„ ์ ์šฉ์ด ๋‹ค ๋˜๋Š”๋ฐ
transform์€ ์†์„ฑ ์“ฐ๋ ค๋ฉด ๊ฐ™์ด ์จ์•ผํ•œ๋‹ค!!!

transform:scale(2,2);
transform:rotate(45deg); ๋กœ ์“ฐ๋ฉด ์ œ์ผ ๋งˆ์ง€๋ง‰์— ์žˆ๋Š” rotate๋งŒ ๋จนํžŒ๋‹ค
๊ทธ๋ž˜์„œ
transform:scale(2,2) rotate(45deg); ์ด๋ ‡๊ฒŒ ๊ฐ™์ด ์จ์ค˜์•ผํ•œ๋‹ค

=================================================
๐Ÿ’ก :hover (๋งˆ์šฐ์Šค์˜ค๋ฒ„) ์ผ๋•Œ!!!

๊ณตํ†ต => ๊ณตํ†ต์ ์ธ ์„ฑ์งˆ ๋ชจ์•„๋‘๋Š” boxํด๋ž˜์Šค ํ•˜๋‚˜ ๋งŒ๋“ค์–ด์ฃผ๊ณ 

transition => 1ํšŒ๋งŒ!!!!! (๋งˆ์šฐ์Šค๋–ผ๋ฉด ๋‹ค์‹œ ์ œ์ž๋ฆฌ๋กœ ๋Œ์•„๊ฐ)

  1. ๋งˆ์šฐ์Šค ์˜ค๋ฒ„ํ–ˆ์„๋•Œ ๋ฐ”๋€Œ์–ด์•ผ ํ•˜๋Š” ์‚ฌํ•ญ๋“ค ์ž…๋ ฅํ•ด์ฃผ๊ณ 
    .container:hover > .box1 {
    width: 400px;
    height: 100px;
    }
    .container:hover > .box3 {
    margin-left: 200px;
    }
    .container:hover > .box2 {
    background-color: purple;
    }
    .box4:hover {
    border: 7px solid red;
    }
    .box5:hover {
    border: 7px solid red;
    }

  2. ๊ฐ๊ฐ box1, box2, box3, box4, box5 ๋งˆ๋‹ค
    transition-property: all;
    transition-duration: 1s;
    transition-timing-function: linear;
    ์žก์•„์ฃผ๊ณ 
    (ํœ™๋ฐ”๋€Œ๋Š” ํšจ๊ณผ๋ฅผ ์ฃผ๊ณ ์‹ถ์œผ๋ฉด transition: ์†์„ฑ์„ hover์— ๋„ฃ์–ด์ฃผ๋ฉด ํœ™๋ฐ”๋€๋‹ค! -> hover์•ˆ์— transition์†์„ฑ์ด ์žˆ์œผ๋‹ˆ๊นŒ hover ๊ธฐ๋Šฅ์ด ๋๋‚˜๋ฒ„๋ฆฌ๋ฉด(๋งˆ์šฐ์Šค๋ฅผ ๋–ผ๋ฒ„๋ฆฌ๋ฉด) transition๋„ ๋๋‚˜๋ฒ„๋ฆฌ๋‹ˆ๊นŒ ํœ™๋ฐ”๋€Œ๋Š”๊ฒƒ!)

animation => ๋ฌด์ œํ•œ๋ฐ˜๋ณต!!!!! (๋งˆ์šฐ์Šค๋–ผ๋ฉด ๊ทธ์ž๋ฆฌ์—์„œ ๋ฉˆ์ถค)

  1. ๋จผ์ € @keyframes๋กœ ์• ๋‹ˆ๋ฉ”์ด์…˜ ํšจ๊ณผ๋“ค์„ ๋งŒ๋“ค์–ด์ค€๋‹ค
    @keyframes box1-ani {
    0% {
    width: 100px;
    height: 100px;
    }

    100% {
         width: 400px;
         height: 100px;
    }

    }
    @keyframes box3-ani {
    0% {
    left: 0px;
    }

    100% {
        left: 200px;
    }

    }

  2. ๊ทธ ๋‹ค์Œ ์ ์šฉํ•˜๊ณ ์‹ถ์€ ๋ฐ•์Šค์— animation-name: box1-ani;์„ ์ค˜์„œ animation ์ ์šฉ์‹œํ‚จ๋‹ค ๊ทธ๋ฆฌ๊ณ  ๋งˆ์šฐ์Šค์˜ค๋ฒ„ํ–ˆ์„๋•Œ ํšจ๊ณผ๊ฐ€ ๋‚˜ํƒ€๋‚˜์•ผ ํ•˜๋Š”๊ฑฐ๋‹ˆ๊นŒ ๊ฐ€๋งŒํžˆ ์žˆ์„๋• ์ •์ง€ํ•˜๊ณ  ์žˆ๊ฒŒ animation-play-state: paused;์„ ์ฃผ๊ณ 
    .box1 {
    background-color: red;
    animation-name: box1-ani;
    animation-duration: 2s;
    animation-iteration-count: infinite;
    animation-direction: alternate;
    position: relative;
    animation-play-state: paused;
    }
    .box3 {
    background-color: black;
    animation-name: box3-ani;
    animation-duration: 1s;
    animation-iteration-count: infinite;
    animation-direction: alternate;
    position: relative;
    animation-play-state: paused;
    animation-fill-mode: both;
    }

  3. ๊ทธ๋ฆฌ๊ณ  ๋งˆ์šฐ์Šค์˜ค๋ฒ„ํ–ˆ์„๋•Œ ํšจ๊ณผ๊ฐ€ ๋‚˜ํƒ€๋‚˜๊ฒŒ ํ•œ๋‹ค!
    .container:hover > .box1 {
    animation-play-state: running;
    }
    .container:hover > .box3 {
    animation-play-state: running;
    }

โœ๏ธ์—ฐ์Šต๋ฌธ์ œ

๊ตด๋Ÿฌ๊ฐ€๋Š” ์‚ฌ๊ฐํ˜• ํ‘œํ˜„ํ•˜๊ธฐ

<body>
  <style>
      * {
          margin: 0;
          padding: 0;
          box-sizing: border-box;
      }

      .box {
          margin: 30px;
          width: 100px;
          height: 100px;
          background-color: blue;
          position: relative; //left ๋‚˜ํƒ€๋‚˜๊ฒŒ ํ•˜๊ธฐ์œ„ํ•ด!
          animation-name: box-ani;
          animation-duration: 3s;
          animation-iteration-count: infinite;
          animation-direction: alternate;
      }

       @keyframes box-ani {
          0% {
              background-color: blue;
              left: 0px;
          }
          50% {
              background-color: orange;
              left: 200px;
              transform: rotate(180deg);
          }
          100% {
              background-color: pink;
              left: 400px;
              transform: rotate(360deg);
          }
       }
  </style>
</body>
<body>
    <div class="box"></div>
</body>

=> ๐Ÿ’ป
์ด๋Ÿฐ์‹์œผ๋กœ ๋ฐ๊ตด๋ฐ๊ตด ๊ตด๋Ÿฌ๊ฐ€๋Š” ํ˜•ํƒœ์˜ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜จ๋‹ค



๐Ÿ“– flexโญ

์ปจํ…Œ์ด๋„ˆ => ์ปจํ…Œ์ด๋„ˆ์— flex๋ฅผ ์žก์•„์ฃผ๊ณ  ์•ˆ์— ์•„์ดํ…œ์„ ์ •๋ ฌ!!!!!!
-์•„์ดํ…œ
-์•„์ดํ…œ

๐Ÿ’ก์ ์šฉ๐Ÿ’ก

  1. ์ปจํ…Œ์ด๋„ˆ ์•ˆ์— display: flex; ๋ฅผ ๋„ฃ๋Š”๋‹ค
  2. ์ฃผ์ถ•์„ ๋ฐ”๊พธ๊ณ  ์‹ถ์œผ๋ฉด flex-direction: column; ์œผ๋กœ ์ง€์ •ํ•œ๋‹ค (๊ธฐ๋ณธ๊ฐ’์€ row(ํ–‰,๊ฐ€๋กœ))
  3. ์ค„๋ฐ”๊ฟˆ ํ•˜๊ณ  ์‹ถ์œผ๋ฉด flex-wrap: wrap;์œผ๋กœ ์ง€์ •!
  4. ์ฃผ์ถ• ๊ธฐ์ค€ ์ •๋ ฌ์€ justify-content: center;
    ๊ต์ฐจ์ถ• ๊ธฐ์ค€ ์ •๋ ฌ์€ align-items: center; ๋กœ ์ง€์ •!
    ์•„์ดํ…œ ๊ฐ์ž ์ž์ฒด์ •๋ ฌ ๊ทธ ์•„์ดํ…œ์— ๊ฐ€์„œ ๋”ฐ๋กœ align-self: flex-start;๋กœ ์ง€์ •!

๋ ˆ์ด์•„์›ƒ : ํ™”๋ฉด์˜ ๋ฐฐ์น˜๊ตฌ์กฐ

  • ์ปจํ…Œ์ด๋„ˆ
  • ๋‚ด๋ถ€ ์•„์ดํ…œ
  • ์ •๋ ฌ๊ธฐ์ค€
    ์ฃผ์ถ•(๊ฐ€๋กœ,์„ธ๋กœ)
    ๊ต์ฐจ์ถ•(์„ธ๋กœ,๊ฐ€๋กœ)

1. flex ์†์„ฑ ์ ์šฉ

display : inline, block, inline-block
display : flex, inline-flex

2. ์ฃผ์ถ• ์ง€์ •

flex-direction
row : ๊ฐ€๋กœ์ถ•
row-reverse : ๊ฐ€๋กœ์ถ• ์—ญ๋ฐฉํ–ฅ
column : ์„ธ๋กœ์ถ•
column-reverse : ์„ธ๋กœ์ถ• ์—ญ๋ฐฉํ–ฅ

3. ์ค„๋ฐ”๊ฟˆ ์ฒ˜๋ฆฌ์—ฌ๋ถ€

flex-wrap
nowrap : ์ค„๋ฐ”๊ฟˆX
wrap : ์ค„๋ฐ”๊ฟˆO
wrap-reverse : ์ค„๋ฐ”๊ฟˆO-์—ญ๋ฐฉํ–ฅ

flex-flow: row nowrap; => ๊ฐ€๋กœ์ถ• ์ค„๋ฐ”๊ฟˆ
(direction) (wrap)

4. โญ์ •๋ ฌ

1) ์ฃผ์ถ• ์ •๋ ฌ : justify-content @

flex-start : (์ฃผ์ถ•)์‹œ์ž‘ ๊ธฐ์ค€ ์ •๋ ฌ
flex-end : (์ฃผ์ถ•)๋ ๊ธฐ์ค€ ์ •๋ ฌ
center : ๊ฐ€์šด๋ฐ ์ •๋ ฌ
space-between : ์•„์ดํ…œ ์‚ฌ์ด ๊ฐ„๊ฒฉ ๊ท ์ผ
space-around : ์•„์ดํ…œ ๋‘˜๋ ˆ ๊ฐ„๊ฒฉ ๊ท ์ผ (margin๊นŒ์ง€ ํฌํ•จ)
space-evenly : ์•„์ดํ…œ ์‚ฌ์ด+์–‘๋ ๊ฐ„๊ฒฉ ๊ท ์ผ (์‚ฌ์ด๋ฅผ ์–‘๋๊ฐ„๊ฒฉ ์‚ฌ์ด์— ๋งž์ถฐ)

2) ๊ต์ฐจ์ถ• ์ •๋ ฌ : align-items @

flex-start : (๊ต์ฐจ์ถ•)์‹œ์ž‘ ๊ธฐ์ค€ ์ •๋ ฌ
flex-end : (๊ต์ฐจ์ถ•)๋ ๊ธฐ์ค€ ์ •๋ ฌ
center : ๊ฐ€์šด๋ฐ ์ •๋ ฌ @
stretch : ๊ต์ฐจ์ถ• ๋ฐฉํ–ฅ์œผ๋กœ ๋Š˜์–ด๋‚จ
baseline : ์•„์ดํ…œ baseline๊ธฐ์ค€ ์ •๋ ฌ

3) ์•„์ดํ…œ ๊ต์ฐจ์ถ• ์ž์ฒด ์ •๋ ฌ : align-self

4) ์—ฌ๋Ÿฌ์ค„์ผ๋•Œ ๊ต์ฐจ์ถ• ์ •๋ ฌ : align-content (align-items๋ž‘ ๊ฐ™์ด์“ฐ๊ธฐ์—” ์• ๋งค,, ๊ฑ ์ฒ˜์Œ๋ถ€ํ„ฐ ์‚ฌ์ด์ฆˆ๋ฅผ ์ž˜๋งž์ถ”๋ž˜)

๐Ÿ’Ž์ •๋ฆฌ
display: flex;

flex-direction: column; (๊ธฐ๋ณธ๊ฐ’์ด row์•ผ ๊ทธ๋ž˜์„œ ํ–‰์œผ๋กœ ๋ฐ”๊พธ๊ณ  ์‹ถ์„๋•Œ!)

flex-wrap: wrap; (์ค„๋ฐ”๊ฟˆ ํ•˜๊ณ  ์‹ถ์„๋•Œ)

justify-content: flex-start, flex-end, center, space-between, space-around, space-evenly; (์ฃผ์ถ• ์ •๋ ฌ)

align-items: flex-start, flex-end, center, stretch, baseline; (๊ต์ฐจ์ถ• ์ •๋ ฌ)

align-self: flex-start, flex-end, center, stretch, baseline; (์•„์ดํ…œ ๊ต์ฐจ์ถ• ์ž์ฒด ์ •๋ ฌ)

align-content: flex-start, flex-end, center, space-between, space-around, space-evenly stretch; (์—ฌ๋Ÿฌ์ค„์ผ๋•Œ ๊ต์ฐจ์ถ• ์ •๋ ฌ)

profile
๋’ค์ฃฝ๋ฐ•์ฃฝ ๋ฒจ๋กœ๊ทธ
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€