[TIL] 220201

dev·2022년 2ė›” 1ėž
0

TIL

ëŠĐ록 ëģīęļ°
166/204
post-thumbnail

📝 ė˜Ī늘 한 ęēƒ

  1. flexbox

📚 ë°°ėšī ęēƒ

1. flexbox

1) flex-wrap

flexbox는 ęļ°ëģļė ėœžëĄœ flex-wrapėī nowrap(ęļ°ëģļ값)ėž 때 ę·ļ itemë“Ī뗐 ëķ€ė—Žëœ width ę°’ė„ ëŽīė‹œí•˜ëĐīė„œ ëŠĻ든 itemë“Īė„ 한 ė΄뗐 ėœ„ėđ˜ė‹œí‚Ļë‹Ī.

flex-wrap: wrapė„ ė§€ė •í•˜ëĐī flexboxė˜ item뗐 ëķ€ė—Ží•œ 프로퍾티(width 등)뗐 따띾 itemë“Īėī ë°°ėđ˜ëœë‹Ī.

2) wrap-reverse

flex-wrap

<div class="father">
  <div class="child">1</div>
  <div class="child">2</div>
  <div class="child">3</div>
  <div class="child">4</div>
  <div class="child">5</div>
  <div class="child">6</div>
  <div class="child">7</div>
</div>
.father {
  display: flex;
  justify-content: space-around;
  align-content: space-around;
  flex-wrap: wrap; /* 또는 flex-wrap: wrap-reverse */
  height: 100vh;
}

.child {
  width: 100px;
  height: 100px;
  color: white;
  background-color: lightblue;
  /* ðŸ’Ą ėžė‹ div뗐 flex ė†ė„ąė„ ëķ€ė—Ží•œ ėīėœ ëŠ” div ė•ˆė˜ 텍ėŠĪíŠļëĨž ėΑ땙 ė •ë Ží•˜ęļ° ėœ„í•īė„œėīë‹Ī. */
  display: flex;
  justify-content: center;
  align-items: center;
}

ðŸ’Ą flex-direction뗐 row-reverse 또는 column-reverse ę°’ė„ ėĢžė—ˆė„ ë•Œė™€ ęĩŽëķ„í•īė•ž 한ë‹Ī.
flex-directionė—ė„œė˜ reverse는 ėĢžėķ•ė˜ ė‹œėž‘ė ęģž ëė ė„ 바ęūļ는 반ëĐī,
flex-wrapė—ė„œė˜ reverse는 ėš”ė†Œę°€ 나ė—ī되는 ė‹œėž‘ė ęģž ëė ė„ 바ęūžë‹Ī.

3) align-content

cross axis ėƒė— itemë“Ī ė™ļė—ë„ ë‚Ļė€ ęģĩ간ėī ėžˆė„ 때(flex container뗐 height ę°’ė„ 따로 맀렕í•īėĪ€ ęē―뚰 등) flex container ë‚īė—ė„œ lineė„ ė •ë Ží•˜ęļ° ėœ„í•ī ė‚ŽėšĐ한ë‹Ī.

justify-contentëĨž main axis ë‚īė˜ ę°ę°ė˜ itemë“Īė„ ė •ë Ží•  때 ė‚ŽėšĐ하는 ęēƒęģž ëđ„ėŠ·í•˜ë‹Ī.

4) flex-shrink, flex-grow

(1) flex-shrink

flex-shrinkė˜ ęļ°ëģļę°’ė€ 1ėīë‹Ī.
screen 큎ęļ°ëĨž ëģ€ęē―í•Ļ뗐 따띾 flex containerė˜ 큎ęļ°ę°€ ėĪ„ė–īë“Īė–ī flex itemė˜ 큎ęļ°ę°€ flex containerė˜ 큎ęļ°ëģīë‹Ī ėŧĪėĄŒė„ 때 ëŠĻ든 flex itemë“Īė˜ 큎ęļ°ëĨž ėžė •í•˜ęēŒ ėž‘ęēŒ ë§Œë“ ë‹Ī.

값ėī 0ėž 때는 screenė„ ė•„ëŽīëĶŽ ėĪ„ė—Žë„ ėĢžëģ€ė˜ ë‹ĪëĨļ itemėī ëģīėīė§€ ė•ŠęēŒ ë ė§€ė–ļė • flex-shrinkëĨž 0ėœžëĄœ ė§€ė •í•œ itemė˜ 큎ęļ°ëŠ” ė›ëž˜ 큎ęļ°ė—ė„œ ëģ€í•˜ė§€ ė•ŠëŠ”ë‹Ī.

값ėī 2가 되ëĐī ë‹ĪëĨļ itemë“Īëģīë‹Ī 2배만큾 더 ėž‘ęēŒ ėĪ„ė–ī든ë‹Ī.

(2) flex-grow

flex-growė˜ ęļ°ëģļę°’ė€ 0ėīë‹Ī.
screen 큎ęļ°ëĨž ëģ€ęē―í•Ļ뗐 따띾 flex containerė˜ 큎ęļ°ę°€ ėŧĪė ļ flex itemė˜ 큎ęļ°ę°€ flex containerė˜ 큎ęļ°ëģīë‹Ī ėž‘ė•„ė ļ ęģĩ간ėī ë‚Ļė•„ë„(ėķ”ę°€ëĄœ ęģĩ간ėī ėƒęēĻ도) flex itemė˜ 큎ęļ°ëŠ” ëģ€í•˜ė§€ ė•ŠëŠ”ë‹Ī.(ėŧĪ맀맀 ė•ŠëŠ”ë‹Ī.)

ë§Žė€ itemë“Ī ėĪ‘ í•˜ë‚˜ė˜ itemė˜ flex-grow 값ėī 1ėž 때는 í•īë‹đ itemė˜ 큎ęļ°ę°€ screenėī ėŧĪ말뗐 따띾 ėķ”ę°€ëĄœ ėƒęļī ęģĩę°„ė„ ëŠĻ두 ė°Ļė§€í•œ ë§Œížė˜ 큎ęļ°ëĄœ ėŧĪė§€ęēŒ ëœë‹Ī.

flex-grow 값ėī 각각 1, 2ėļ itemėī 두 개가 ėžˆë‹ĪëĐī screenėī ėŧĪ말뗐 따띾 ėķ”ę°€ëĄœ ėƒęļī ęģĩę°„ė„ 1:2ė˜ ëđ„ėœĻ로 나눠 氀맀ëа ę·ļ만큾 itemė˜ 큎ęļ°ę°€ ėŧĪė§€ęēŒ ëœë‹Ī.

5) flex-basis

flex itemė˜ 큎ęļ°ę°€ ëģ€í•˜ęļ° ė „ė— ėīˆęļ° íŽęļ°ëĨž ė„Īė •í•˜ęļ° ėœ„í•ī ė‚ŽėšĐ한ë‹Ī.
flex growëĨž ė‚ŽėšĐ하ëĐī flex-basis ę°’ė€ ëŽīė‹œëœë‹Ī.

6) flexbox froggy

í†ĩęģž


âœĻ ë‚īėž 할 ęēƒ

  1. grid
profile
dev log

0ę°œė˜ 댓ęļ€