๐Ÿ“

Flex

1. Flex1.1. ๋“ค์–ด๊ฐ€๊ธฐ์— ์•ž์„œ1.2. Flex๋ž€?1.3. ๋‹น์‹ ์ด Flex๋ฅผ ์•Œ๋ฉด ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ๊ฒƒ๋“ค : Flex ์†์„ฑ์„ ํ†ตํ•ด ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ๋ ˆ์ด์•„์›ƒ ์†Œ๊ฐœ1.4. Flex์˜ ํŠน์ง•1.5. axis์™€ cross-axis1.5.1. axis๋ž€?1.5.2. ์ฃผ์ถ•๊ณผ ๊ต์ฐจ์ถ•1.5.3. dir ํŠน์„ฑ1.5.4. writing mode์— ๋”ฐ๋ผ ๋ฐ”๋€Œ๋Š” ์ถ•1.6. ๊ธฐ๋ณธ ์†์„ฑ ์ •๋ณด1.6.1. Flex ์•Œ์•„๋ณด๊ธฐ2. Flex-direction2.1. flex-direction : row2.2. flex-direction : row-reverse2.3. flex-direction : column2.4. flex-direction : column-reverse3. Justify-content3.1. flex-start3.2. flex-end3.3. center3.4. space-between, space-around, space-evenly3.4.1. space-between3.4.2. space-around3.4.3. space-evenly3.5. ์ž์ฃผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ์†์„ฑ๋“ค3.5.1. justify-content : normal3.5.2. justify-content : initial3.5.3. justify-content : inherit3.5.4. justify-content : revert3.5.5. justify-content : unset3.5.6. firefox์—์„œ๋งŒ ์ง€์›ํ•˜๋Š” ์†์„ฑ4. Align-items, Align-content4.1. align-items4.2. align-content5. Flex-wrap5.1. flex-wrap : nowrap5.2. flex-wrap : wrap5.3. flex-wrap : wrap-reverse6. Flex-basis6.1. flex-basis๋ž€?6.2. flex-basis์— ๋“ค์–ด๊ฐ€๋Š” ๊ฐ’6.3. flex-basis์˜ ์œ ์—ฐ์„ฑ6.4. flex-basis์™€ width/height์˜ ๊ด€๊ณ„6.5. flex-basis : auto; ์™€ flex-basis : 0;6.6. flex-basis : content;6.7. flex-basis๋ณด๋‹ค๋Š” flex ์ถ•์•ฝ ์†์„ฑ์„! (W3C)6.8. flex-basis ํ˜ธํ™˜์„ฑ7. Flex-grow7.1. flex-grow๋ž€?7.2. flex-grow ๊ธฐ๋Šฅ : ํ™•์žฅ ๋˜๋Š” ๊ณ ์ •7.3. flex-grow ์‚ฌ์šฉ ์‹œ ์ฃผ์˜ํ•  ์ 7.4. flex ์ถ•์•ฝ ์†์„ฑ7.5. flex-shrink๋ณด๋‹ค๋Š” flex ์ถ•์•ฝ ์†์„ฑ์„! (W3C)7.6. flex-grow ํ˜ธํ™˜์„ฑ8. Flex-shrink8.1. Flex-shrink ๋ž€?8.2. Flex-shrink ๊ธฐ๋Šฅ: ์ถ•์†Œ ๋˜๋Š” ๊ณ ์ •8.3. Flex-shrink ์‚ฌ์šฉ ์‹œ ์ฃผ์˜ํ•  ์ 8.4. Flex ์ถ•์•ฝ ์†์„ฑ8.5. Flex-shrink๋ณด๋‹ค๋Š” Flex ์ถ•์•ฝ ์†์„ฑ์„! (W3C)8.6. Flex-shrink ํ˜ธํ™˜์„ฑ (caniuse)9. ๊ทธ ๋ฐ–์˜ Flex-item์— ์‚ฌ์šฉํ•˜๋Š” ์†์„ฑ๋“ค9.1. align-self9.2. order9.3. z-index10. IE ์ง€์›์„ ์œ„ํ•œ Flex10.1. -ms- prefix ์‚ฌ์šฉ ์˜ˆ์‹œ10.2. IE์—์„œ์˜ Flex ์ด์Šˆ11. ์„ฑ๋ฐฐ ๋ ˆ์ด์•„์›ƒ ๊ทธ๋ฆฌ๊ธฐ11.1. Flex ์†์„ฑ์„ ์ด์šฉํ•˜์—ฌ ๊ธฐ๋ณธ ์„ฑ๋ฐฐ ๋ ˆ์ด์•„์›ƒ ๊ตฌํ˜„ํ•˜๊ธฐ11.2. Flex ์†์„ฑ์„ ์ด์šฉํ•˜์—ฌ ๋ณ€ํ˜•๋œ ์„ฑ๋ฐฐ ๋ ˆ์ด์•„์›ƒ ๊ตฌํ˜„ํ•˜๊ธฐ
ย 
ย 
ย 

1. Flex

1.1. ๋“ค์–ด๊ฐ€๊ธฐ์— ์•ž์„œ

๊ธฐ๊ธฐ๊ฐ€ ๋‹ค์–‘ํ•ด์ง์— ๋”ฐ๋ผ ํ™”๋ฉด ํฌ๊ธฐ๋„ ๋‹ค์–‘ํ•˜๊ฒŒ ๋ณ€ํ™”๋˜์—ˆ๋‹ค. ๋‹ค์–‘ํ•œ ๊ธฐ๊ธฐ์— ๋Œ€์‘ํ•˜๊ธฐ ์œ„ํ•ด ์›น ์„œ๋น„์Šค๋ฅผ ์œ ์—ฐํ•˜๊ฒŒ ๋งŒ๋“œ๋Š” ๊ฒƒ์€ ์„ ํƒ์ด ์•„๋‹Œ ํ•„์ˆ˜๊ฐ€ ๋˜์—ˆ๋‹ค.
๋‹ค์–‘ํ•œ ํ™”๋ฉด์˜ ํฌ๊ธฐ์— ๋งž์ถ”์–ด ์œ ์—ฐํ•˜๊ฒŒ ๋Œ€์‘ํ•  ์ˆ˜ ์žˆ๋Š” ๋ ˆ์ด์•„์›ƒ์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด ์ƒˆ๋กญ๊ฒŒ ์ถ”๊ฐ€๋œ ์†์„ฑ์ด Flex์™€ Grid์ด๋‹ค. Flex๋Š”ย 1์ฐจ์› ์ ์ธ ๋ ˆ์ด์•„์›ƒ์„ ์žก์„ ๋•Œ ์‚ฌ์šฉํ•˜๋ฉฐ, grid๋Š”ย 2์ฐจ์› ์ ์ธ ๋ ˆ์ด์•„์›ƒ์„ ์žก์„ ๋•Œ ์šฉ์ดํ•˜๋‹ค.
Flex๋Š” ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ) ์•„๋ž˜์—์„œย ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)๋“ค์ด ํ•œ ๋ฐฉํ–ฅ์œผ๋กœ ๋ฐฐ์น˜๊ฐ€ ๋œ๋‹ค. ๋”ฐ๋ผ์„œ ํ–‰ ๋˜๋Š” ์—ด ํ•œ ๊ฐ€์ง€ ๋ฐฉํ–ฅ์œผ๋กœ ๋ ˆ์ด์•„์›ƒ์„ ๋ฐฐ์น˜ํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ์— ์‚ฌ์šฉํ•œ๋‹ค. ๋˜ํ•œ ๋‹ค์–‘ํ•œ ์†์„ฑ์„ ํ†ตํ•ด ์ž์‹ ์š”์†Œ ์‚ฌ์ด๋ฅผ ์ผ์ •ํ•œ ๊ฐ„๊ฒฉ์œผ๋กœ ์ค„ ์ˆ˜ ์žˆ๊ณ  ์ •๋ ฌํ•˜๊ธฐ๊ฐ€ ๋งค์šฐ ํŽธํ•˜๋‹ค.
Grid๋Š” ํ–‰๊ณผ ์—ด Matrix ํ˜•ํƒœ๋กœ ๋ ˆ์ด์•„์›ƒ์„ ๋ฐฐ์น˜ํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ ์‚ฌ์šฉํ•œ๋‹ค. ์›ํ•˜๋Š” ์š”์†Œ๋ฅผ ์–ด๋””์„œ๋ถ€ํ„ฐ ์–ด๋””๊นŒ์ง€, ์–ด๋Š ๋ฐฉํ–ฅ์œผ๋กœ ์ฐจ์ง€ํ•˜๊ฒŒ ํ•  ๊ฑด์ง€ ์ •ํ•˜๊ณ  ๋ฐฐ์น˜ํ•˜๋ฉด ๋œ๋‹ค.
์ง€๊ธˆ๋ถ€ํ„ฐ โ€˜์•Œ์•„์„œ ์ž˜ ๋”ฑ ๊น”๋”ํ•˜๊ณ  ์„ผ์Šค ์žˆ๊ฒŒโ€™ Flex๋ฅผ ๋ฐฐ์›Œ๋ณด์ž.

1.2. Flex๋ž€?

๊ฐ™์€ ์ด๋ฏธ์ง€๋กœ grid๋„ ์„ค๋ช…ํ•˜๋‹ˆ ๋น„๊ตํ•ด๋ณด๋ฉด์„œ ๋ณด๊ธธ ๊ถŒํ•œ๋‹ค. ์ฒซ๋ฒˆ์งธ ์ด๋ฏธ์ง€์— ์žˆ๋Š” ๋นจ๊ฐ„์ƒ‰ ๋ฐ•์Šค๋ฅผ ๋ชจ๋‘ flex๋กœ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค.
notion imagenotion image
notion imagenotion image

1.3. ๋‹น์‹ ์ด Flex๋ฅผ ์•Œ๋ฉด ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ๊ฒƒ๋“ค : Flex ์†์„ฑ์„ ํ†ตํ•ด ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ๋ ˆ์ด์•„์›ƒ ์†Œ๊ฐœ

์นด๋“œ๋ฅผ ์ˆœ์„œ๋Œ€๋กœ ๋ฐฐ์น˜ํ•  ์ˆ˜ ์žˆ๊ณ , ๊ฐ ์นด๋“œ ๋‚ด๋ถ€์—์„œ Flex๋ฅผ ์ด์šฉํ•ด์„œ ์š”์†Œ๋ฅผ ๋ณด๋‹ค ์‰ฝ๊ฒŒ ๋ฐฐ์น˜ํ•  ์ˆ˜ ์žˆ๋‹ค.
flex๋กœ ๊ตฌํ˜„๋œ UI - 1flex๋กœ ๊ตฌํ˜„๋œ UI - 1
flex๋กœ ๊ตฌํ˜„๋œ UI - 1
ย 
Flex๋ฅผ ํ™œ์šฉํ•œ ํ™ˆํŽ˜์ด์ง€๋‹ค. ์ „์ฒด์ ์ธ ๋ ˆ์ด์•„์›ƒ์„ Flex๋กœ ๋ฐฐ์น˜ํ•˜๊ณ , ์•„์ดํ…œ๋“ค ๋˜ํ•œ Flex๋ฅผ ์‚ฌ์šฉํ•œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด์ฒ˜๋Ÿผ Flex๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด, ๊ธฐ์กด์— float๋ฅผ ์ด์šฉํ•œ ๋ฐฉ๋ฒ•๋ณด๋‹ค ๋”์šฑ ์‰ฝ๊ณ  ๊ฐ„ํŽธํ•˜๊ฒŒ ์š”์†Œ๋“ค์€ ๋ฐฐ์น˜ํ•  ์ˆ˜ ์žˆ๋‹ค.
ย 
flex๋กœ ๊ตฌํ˜„๋œ UI - 2flex๋กœ ๊ตฌํ˜„๋œ UI - 2
flex๋กœ ๊ตฌํ˜„๋œ UI - 2

1.4. Flex์˜ ํŠน์ง•

Flex๋Š” ๋ถ€๋ชจ์™€ ์ž์‹ ํƒœ๊ทธ๊ฐ€ ํ•„์š”ํ•˜๊ณ , ๋ถ€๋ชจ ์š”์†Œ(flex-container)์™€ ์ž์‹ ์š”์†Œ(flex-item)์— ์ ์šฉํ•˜๋Š” ์†์„ฑ์ด ๊ตฌ๋ถ„๋˜์–ด ์žˆ๋‹ค.
์ด๋•Œ ์†์„ฑ์˜ ์˜ํ–ฅ์€ ์ปจํ…Œ์ด๋„ˆ์˜ ์ง๊ณ„์ž์‹๊นŒ์ง€๋งŒ ์˜ํ–ฅ์„ ์ค€๋‹ค๋Š” ํŠน์ง•์ด ์žˆ์œผ๋‹ˆ ์ฃผ์˜ํ•ด์•ผ ํ•œ๋‹ค.
flex-container์—๋Š” ์ •๋ ฌ ๋ฐฉ์‹๊ณผ item์˜ ๋ฐฐ์น˜ ํ๋ฆ„์„ ์ •์˜ํ•˜๊ณ , flex-item์—๋Š” ํฌ๊ธฐ, ์†์„ฑ, ์ˆœ์„œ๋ฅผ ์ •์˜ํ•œ๋‹ค.
  • flex-container์˜ ์†์„ฑ : flex-direction, flex-wrap, justify-content, align-items, align-content ๋“ฑ
  • flex-item์˜ ์†์„ฑ : flex, flex-grow, flex-shrink, flex-basis, align-self, order, z-index ๋“ฑ
ย 
ใ…ค
๊ธฐ๋ณธ ์†์„ฑ
์ ์šฉ ๋Œ€์ƒ
flex-direction
row
flex containers
justify-content
normal
flex containers
align-items
normal
all elements
align-content
normal
multi-line flex containers
flex-wrap
nowrap
flex containers
flex-basis
auto
flex items
flex-grow
0
flex items
flex- shrink
1
flex items
์–ด๋– ํ•œ ์†์„ฑ์„ ์ ์šฉํ•ด์•ผ ํ•˜๋Š”์ง€ ํ—ท๊ฐˆ๋ฆฌ๋Š” ๊ฒฝ์šฐ, ์ปจํ…Œ์ด๋„ˆ์— flex ์†์„ฑ์„ ์ ์šฉํ•œ ๋’ค ํฌ๋กฌ ๊ฐœ๋ฐœ์ž ๋„๊ตฌ์˜ ์Šคํƒ€์ผ ํƒญ์„ ํ™•์ธํ•˜๋ฉด ์ข‹๋‹ค. ์ฃผ์š”ํ•œ ์†์„ฑ ๋‹ค์„ฏ ๊ฐ€์ง€๋ฅผ GUI ๊ธฐ๋Šฅ์œผ๋กœ ์ œ๊ณตํ•˜์—ฌ ์ ์šฉ๋œ ๋ชจ์Šต์„ ํ™•์ธํ•ด๋ณผ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
ย 
notion imagenotion image

1.5. axis์™€ cross-axis

1.5.1. axis๋ž€?

axis๋กœ ์ž์‹ ์š”์†Œ์˜ ์ •๋ ฌ ๋ฐฉํ–ฅ์„ ์ œ์–ดํ•  ์ˆ˜ ์žˆ๋‹ค. ํ–‰๋ฐฉํ–ฅ, ์—ด๋ฐฉํ–ฅ์œผ๋กœ ๊ฐ๊ฐ ๋ฐ˜๋Œ€ ๋ฐฉํ–ฅ๋„ ์ง€์›ํ•œ๋‹ค.
notion imagenotion image

1.5.2. ์ฃผ์ถ•๊ณผ ๊ต์ฐจ์ถ•

  • Main Axis
Flex์˜ ์ฃผ์ถ•์ด ๋˜๋Š” main axis์˜ ๋ฐฉํ–ฅ์€ flex-direction ์ด๋ผ๋Š” ์†์„ฑ์— ์˜ํ•ด ๊ฒฐ์ •๋œ๋‹ค. ์ด๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋„ค ๊ฐ€์ง€์˜ ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋‹ค.
flex-directionย ์†์„ฑ์—ย row-reverseย ๋˜๋Š”ย column-reverseย ๊ฐ’์„ ์‚ฌ์šฉํ•˜๋ฉด DOM ๊ตฌ์กฐ์™€ ์‹œ๊ฐ์  ํ‘œํ˜„์— ์ฐจ์ด๊ฐ€ ๋ฐœ์ƒํ•˜์—ฌ ์Šคํฌ๋ฆฐ ๋ฆฌ๋”๋กœ ์ ‘๊ทผํ•˜๋Š” ์‚ฌ์šฉ์ž์—๊ฒŒ ์ž˜๋ชป๋œ ์ •๋ณด๋ฅผ ์ „๋‹ฌ ํ•  ๊ฐ€๋Šฅ์„ฑ์ด ์žˆ์œผ๋‹ˆ ์ฃผ์˜๋ฅผ ์š”ํ•œ๋‹ค.
  1. flex-direction: row : flex-direction ์˜ ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ์•„์ดํ…œ๋“ค์ด ํ–‰ ๋ฐฉํ–ฅ, ๊ฐ€๋กœ๋กœ ๋ฐฐ์น˜๋œ๋‹ค.
  1. flex-direction: row-reverse : ์•„์ดํ…œ๋“ค์ด ์—ญ์ˆœ์œผ๋กœ ๊ฐ€๋กœ๋กœ ๋ฐฐ์น˜๋œ๋‹ค.
  1. flex-direction: column : ์•„์ดํ…œ๋“ค์ด ์—ด ๋ฐฉํ–ฅ์œผ๋กœ, ์„ธ๋กœ๋กœ ๋ฐฐ์น˜๋œ๋‹ค.
  1. flex-direction: column-reverse : ์•„์ดํ…œ๋“ค์ด ์—ญ์ˆœ์œผ๋กœ ์„ธ๋กœ๋กœ ๋ฐฐ์น˜๋œ๋‹ค.
ย 
flex-direction:rowflex-direction:row
flex-direction:row
ย 
flex-direction:columnflex-direction:column
flex-direction:column
  • Cross Axis
Cross axis๋Š” Main axis ๋ฐฉํ–ฅ์˜ ์ˆ˜์ง ๋ฐฉํ–ฅ์ด๋‹ค. Main axis๊ฐ€ flex-direction ์— ์˜ํ•ด ๊ฒฐ์ •๋˜์—ˆ๋‹ค๋ฉด, Cross axis๋Š” main axis ๋ฐฉํ–ฅ์— ๋”ฐ๋ผ ๊ฒฐ์ •์ด ๋œ๋‹ค.

1.5.3. dir ํŠน์„ฑ

๐Ÿ’ก
flex๋ฅผ ์ฒ˜์Œ ํ•ด๋ณธ๋‹ค๋ฉด 1.5.3 ์ฑ•ํ„ฐ์™€ 1.5.4 ์ฑ•ํ„ฐ๋Š” ๊ฑด๋„ˆ ๋›ฐ๊ณ  ํ•„์š”ํ•  ๋•Œ ์ฐพ์•„๋ณด๊ธฐ๋ฅผ ๊ถŒ๊ณ ํ•œ๋‹ค.
html ์š”์†Œ ํ…์ŠคํŠธ์˜ ๋ฐฉํ–ฅ์„ฑ์„ ๋‚˜ํƒ€๋‚ด๋Š” ์—ด๊ฑฐ๋œ ์†์„ฑ์ด๋‹ค. ๊ธฐ๋ณธ๊ฐ’์€ auto์ด๋‹ค.
<div dir = "ltr / rtl / auto"> ... </div>
  • ltr : ๊ธ€์ž๋ฅผ ์ฝ๋Š” ๋ฐฉ๋ฒ•์ด ์™ผ์ชฝ์—์„œ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ์“ฐ์ด๋Š” ์–ธ์–ด์ด๋‹ค.
  • rtl : ๊ธ€์ž๋ฅผ ์ฝ๋Š” ๋ฐฉ๋ฒ•์ด ์˜ค๋ฅธ์ชฝ์—์„œ ์™ผ์ชฝ์œผ๋กœ ์ฝ๋Š” ์•„๋ž๊ถŒ ๊ตญ๊ฐ€์—์„œ ์‚ฌ์šฉ๋œ๋‹ค.
  • auto : ๊ธฐ๋ณธ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ•ํ•œ ๋ฐฉํ–ฅ์„ฑ์„ ๊ฐ€์ง„ ๋ฌธ์ž๋ฅผ ์ฐพ์„ ๋•Œ๊นŒ์ง€ ์š”์†Œ ๋‚ด๋ถ€์˜ ๋ฌธ์ž๋ฅผ ๊ตฌ๋ฌธ ๋ถ„์„ํ•˜๊ณ  ์ „์ฒด ์š”์†Œ์— ํ•ด๋‹น ๋ฐฉํ–ฅ์„ฑ์„ ์ ์šฉํ•œ๋‹ค.
ย 
dir ์†์„ฑ์— ๋”ฐ๋ฅธ flex-Axis์˜ ๋ณ€ํ™”
flex-direction:row์™€ flex-direction:row-reverse๋Š” ์ปจํ…Œ์ด๋„ˆ์˜ ๋ฐฉํ–ฅ์„ฑ์— ๋”ฐ๋ผ ์˜ํ–ฅ์„ ๋ฐ›๊ธฐ ๋•Œ๋ฌธ์— dir์ „์—ญ ์†์„ฑ์„ ํ™•์ธํ•ด์•ผ ํ•œ๋‹ค.
ย 
  • ltr
    • flex-direction:row : flex-Axis๋Š” ์™ผ์ชฝ์˜ flex-start์—์„œ ์˜ค๋ฅธ์ชฝ flex-end์ด๋‹ค.
    • flex-direction:row-reverse : flex-Axis๋Š” ์˜ค๋ฅธ์ชฝ flex-start์—์„œ ์™ผ์ชฝ flex-end์ด๋‹ค.
    • container์— dir="ltr" ์ž…๋ ฅ
  • rtl
    • flex-direction:row : flex-Axis๋Š” ์˜ค๋ฅธ์ชฝ์˜ flex-start์—์„œ ์™ผ์ชฝ flex-end์ด๋‹ค.
    • flex-direction:row-reverse : flex-Axis๋Š” ์™ผ์ชฝ flex-start์—์„œ ์˜ค๋ฅธ์ชฝ flex-end์ด๋‹ค.
    • container์— dir="rtl" ์ž…๋ ฅ
<body> <div dir="rtl" class="container"> //container๊ฐ€ rtl๋กœ ๋ณ€ํ™˜๋œ๋‹ค. <div class="item">1</div> <div class="item even">2</div> <div class="item">3</div> </div> </body>
ย 
  • flex-direction:row
notion imagenotion image
.container { display: flex; flex-direction: row; align-items: flex-start; }
ย 
  • flex-direction:row-reverse
notion imagenotion image
.container { display: flex; flex-direction: row-reverse; align-items: flex-start; }
ย 

1.5.4. writing mode์— ๋”ฐ๋ผ ๋ฐ”๋€Œ๋Š” ์ถ•

  • writing mode(์ฝ๊ธฐ ๋ชจ๋“œ)๋ž€?
    • ๋ฌธ์„œ๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ํ…์ŠคํŠธ ํ๋ฆ„ ๋ฐฉํ–ฅ์„ writing mode๋ผ๊ณ  ํ•œ๋‹ค.
ย 
  • writing mode์˜ ์ค‘์š”์„ฑ
    • ์ตœ๊ทผ flex ๋ฐ•์Šค์™€ grid ํ…œํ”Œ๋ฆฟ์„ ์‚ฌ์šฉํ•œ ๋ ˆ์ด์•„์›ƒ์ด ๋งŽ์•„์ง€๊ณ  ์žˆ๋‹ค. ์ด๋•Œ ์šฐ๋ฆฌ๋Š” ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์ธ๋ผ์ธ ๋ฐฉํ–ฅ(ํ…์ŠคํŠธ ๋ฐฉํ–ฅ)์„ ์™ผ์ชฝ์—์„œ ์˜ค๋ฅธ์ชฝ, ๋ธ”๋ก ๋ฐฉํ–ฅ(๋‹จ๋ฝ ๋ฐฉํ–ฅ)์€ ์œ„์—์„œ ์•„๋ž˜๋ผ๊ณ  ์ƒ๊ฐํ•œ๋‹ค. ํ‘œ์ค€ ๋ฐฉํ–ฅ row๋„, ์ธ๋ผ์ธ ๋ฐฉํ–ฅ์ด ๊ฐ€๋กœ์ธ ๊ฒƒ๋„ ์ด์ƒํ•˜๋‹ค๊ณ  ๋Š๋ผ์ง€ ์•Š๋Š”๋‹ค. ํ•˜์ง€๋งŒ ๊ตญ๊ฐ€๋งˆ๋‹ค ์„ค์ •๋œ writing mode๊ฐ€ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ๋‹ค.
      ๋งŒ์•ฝ ์šฐ๋ฆฌ๊ฐ€ ๋งŒ๋“  ํ™ˆํŽ˜์ด์ง€๋ฅผ ์ „ ์„ธ๊ณ„์—์„œ ๋ณด๊ฒŒ ๋œ๋‹ค๋ฉด, writing mode๋ฅผ ๊ณ ๋ คํ•ด์•ผ ํ•˜๋Š” ์ƒํ™ฉ์ด ์ƒ๊ธธ ์ˆ˜๋„ ์žˆ๋‹ค. ์•„์ง์€ ์˜์–ด๊ถŒ ๊ตญ๊ฐ€์—์„œ ์‚ฌ์šฉํ•˜๋Š” horizontal-tb ๋ฐฉํ–ฅ ์ด์™ธ์˜ writing mode๋ฅผ ๋งŽ์ด ์‚ฌ์šฉํ•˜์ง€ ์•Š์ง€๋งŒ, flex์™€ grid ์‹œ๋Œ€๋ฅผ ๋งž์ดํ•˜๋ฉฐ writing mode์— ๋Œ€ํ•œ ์ดํ•ด๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ๋…ผ๋ฆฌ์  ์‚ฌ๊ณ ๋ฅผ ํ™•์žฅํ•˜๋Š” ๊ฒƒ์€ ์ค‘์š”ํ•œ ์ผ์ด๋‹ค.
ย 
๊ฐ€๋กœ ๋ฐฉํ–ฅ์œผ๋กœ ๊ธ€์„ ์ž‘์„ฑํ•  ๋•Œ ์ผ๋ฐ˜์ ์œผ๋กœ ์ ์šฉ๋˜๋Š” ๋ธ”๋ก(๋‹จ๋ฝ)๊ณผ ์ธ๋ผ์ธ(ํ…์ŠคํŠธ) ๋ฐฉํ–ฅ์ด๋‹ค.๊ฐ€๋กœ ๋ฐฉํ–ฅ์œผ๋กœ ๊ธ€์„ ์ž‘์„ฑํ•  ๋•Œ ์ผ๋ฐ˜์ ์œผ๋กœ ์ ์šฉ๋˜๋Š” ๋ธ”๋ก(๋‹จ๋ฝ)๊ณผ ์ธ๋ผ์ธ(ํ…์ŠคํŠธ) ๋ฐฉํ–ฅ์ด๋‹ค.
๊ฐ€๋กœ ๋ฐฉํ–ฅ์œผ๋กœ ๊ธ€์„ ์ž‘์„ฑํ•  ๋•Œ ์ผ๋ฐ˜์ ์œผ๋กœ ์ ์šฉ๋˜๋Š” ๋ธ”๋ก(๋‹จ๋ฝ)๊ณผ ์ธ๋ผ์ธ(ํ…์ŠคํŠธ) ๋ฐฉํ–ฅ์ด๋‹ค.
์„ธ๋กœ ๋ฐฉํ–ฅ์œผ๋กœ ๊ธ€์„ ์ž‘์„ฑํ•  ๋•Œ ์ ์šฉ๋˜๋Š” ๋ธ”๋ก(๋‹จ๋ฝ)๊ณผ ์ธ๋ผ์ธ(ํ…์ŠคํŠธ) ๋ฐฉํ–ฅ์ด๋‹ค.์„ธ๋กœ ๋ฐฉํ–ฅ์œผ๋กœ ๊ธ€์„ ์ž‘์„ฑํ•  ๋•Œ ์ ์šฉ๋˜๋Š” ๋ธ”๋ก(๋‹จ๋ฝ)๊ณผ ์ธ๋ผ์ธ(ํ…์ŠคํŠธ) ๋ฐฉํ–ฅ์ด๋‹ค.
์„ธ๋กœ ๋ฐฉํ–ฅ์œผ๋กœ ๊ธ€์„ ์ž‘์„ฑํ•  ๋•Œ ์ ์šฉ๋˜๋Š” ๋ธ”๋ก(๋‹จ๋ฝ)๊ณผ ์ธ๋ผ์ธ(ํ…์ŠคํŠธ) ๋ฐฉํ–ฅ์ด๋‹ค.
ย 
writing mode ์ข…๋ฅ˜
  • horizontal-tb
    • ํ…์ŠคํŠธ๋ฅผ ์™ผ์ชฝ์—์„œ ์‹œ์ž‘ํ•˜์—ฌ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ์ž‘์„ฑ๋œ๋‹ค. ์˜์–ด๋‚˜ ์•„๋ž์–ด์—์„œ ์ฃผ๋กœ ์‚ฌ์šฉ๋œ๋‹ค.
  • vertical-rl
    • ํ…์ŠคํŠธ๊ฐ€ ์˜ค๋ฅธ์ชฝ์—์„œ ์™ผ์ชฝ์œผ๋กœ ์„ธ๋กœ๋กœ ์ž‘์„ฑ๋œ๋‹ค. ํ•œ๊ตญ, ์ผ๋ณธ, ์ค‘๊ตญ ๋“ฑ์˜ ์•„์‹œ์•„๊ถŒ ๊ตญ๊ฐ€์—์„œ ์„ธ๋กœ ๋ฐฉํ–ฅ์œผ๋กœ ๊ธ€์„ ์ž‘์„ฑํ•  ๋•Œ์—๋งŒ ์ ์šฉ๋œ๋‹ค.
  • vertical-lr
    • ํ…์ŠคํŠธ๊ฐ€ ์™ผ์ชฝ์—์„œ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ์„ธ๋กœ๋กœ ์ž‘์„ฑ๋œ๋‹ค. ๋Œ€ํ‘œ์ ์œผ๋กœ ๋ชฝ๊ณจ์–ด๊ฐ€ ์žˆ๋‹ค.
  • sideways-lr, side-rl
    • horizontal-tb ์†์„ฑ์ฒ˜๋Ÿผ ํ…์ŠคํŠธ๊ฐ€ ๊ฐ€๋กœ๋กœ ์ž‘์„ฑ๋œ๋‹ค. ํ•˜์ง€๋งŒ lr์™€ rl ๋ฐฉํ–ฅ ๋ณ€ํ™”๋Š” ํŒŒ์ด์–ดํญ์Šค์—์„œ๋งŒ ํ™•์ธ ๊ฐ€๋Šฅํ•˜๋‹ค.
writing mode์— ๋”ฐ๋ผ ๋ฐ”๋€Œ๋Š” axis ๋ฐฉํ–ฅ
1) flex-direction: row
horizontal-tb
์ธ๋ผ์ธ๊ณผ ๋ธ”๋ก ๋ฐฉํ–ฅ์ด ๋ชจ๋‘ ๊ฐ€๋กœ์ด๋ฉฐ, Main Axis๋Š” ๊ฐ€๋กœ, Cross Axis ์„ธ๋กœ์ด๋‹ค.
ย 
notion imagenotion image
.container { writing-mode: horizontal-tb; }
<div class="container"> <div class="item">1</div> <div class="item">2</div> <div class="item">3</div> </div>
ย 
ย 
vertical-lr
์ธ๋ผ์ธ ๋ฐฉํ–ฅ๊ณผ ๋ธ”๋ก ๋ฐฉํ–ฅ์ด ๋ชจ๋‘ ์„ธ๋กœ์ด๋ฉฐ Main Axis๋Š” ์„ธ๋กœ, Cross Axis๋Š” ๊ฐ€๋กœ์ด๋‹ค. ๊ธ€์”จ๊ฐ€ ๋ˆ•ํ˜€์ง€๋Š” ์ด์œ ๋Š” writing mode๊ฐ€ ์ „ํ™˜๋˜๋ฉด์„œ ์ธ๋ผ์ธ๊ณผ ๋ธ”๋ก ๋ฐฉํ–ฅ์ด ๋ชจ๋‘ ์„ธ๋กœ๋กœ ๋ฐ”๋€Œ์—ˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
ย 
notion imagenotion image
.container { writing-mode: vertical-lr; }
<div class="container"> <div class="item">1</div> <div class="item">2</div> <div class="item">3</div> </div>
ย 
ย 
2) flex-direction: column
horizontal-tb
์ธ๋ผ์ธ ๋ฐฉํ–ฅ์€ ๊ฐ€๋กœ, ๋ธ”๋ก ๋ฐฉํ–ฅ์€ ์„ธ๋กœ์ด๋ฉฐ Main Axis๋Š” ์„ธ๋กœ, Cross Axis ๊ฐ€๋กœ์ด๋‹ค.
ย 
notion imagenotion image
.container { flex-direction: column; writing-mode: horizontal-tb; }
<div class="container"> <div class="item">1</div> <div class="item">2</div> <div class="item">3</div> </div>
ย 
ย 
vertical-lr
์ธ๋ผ์ธ ๋ฐฉํ–ฅ์€ ์„ธ๋กœ, ๋ธ”๋ก ๋ฐฉํ–ฅ์€ ๊ฐ€๋กœ์ด๋ฉฐ Main Axis๋Š” ๊ฐ€๋กœ, Cross Axis๋Š” ์„ธ๋กœ์ด๋‹ค. row์˜ verticla-lr๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ์„ธ๋กœ ์“ฐ๊ธฐ๋กœ ์ „ํ™˜๋˜์–ด ๊ธ€์”จ๊ฐ€ ๋ˆ•ํ˜€์ง€๊ฒŒ ๋ณด์ธ๋‹ค.
ย 
notion imagenotion image
.container { flex-direction: column; writing-mode: vertical-lr; }
<div class="container"> <div class="item">1</div> <div class="item">2</div> <div class="item">3</div> </div>
ย 

1.6. ๊ธฐ๋ณธ ์†์„ฑ ์ •๋ณด

1.6.1. Flex ์•Œ์•„๋ณด๊ธฐ

Flex๋Š” ์ž์‹์š”์†Œ(์•„์ดํ…œ)์ด ๊ทธ ์ž์‹์š”์†Œ(์•„์ดํ…œ)์„ ํฌํ•จํ•˜๋Š” ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ ๊ณต๊ฐ„์— ๋งž์ถฐ ๊ทธ ํฌ๊ธฐ๋ฅผ ์ค„์ด๊ฑฐ๋‚˜, ๋Š˜์ด๊ณ  ๋˜๋Š” ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์— ๋งž์ถฐ ๊ทธ ์ •๋ ฌ์„ ๋งž์ถ”๋Š” css display์˜ ํ•˜๋‚˜์˜ ์†์„ฑ์ด๋‹ค. flex๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ๊ฐ„๋‹จํ•œ ์˜ˆ๋กœ ์‚ดํŽด๋ณด์ž.
notion imagenotion image
<body> <div class="container"> <div class="item">1</div> <div class="item even">2</div> <div class="item">3</div> <div class="item even">4</div> <div class="item">5</div> </div> </body>
ย 
ย 
์—ฌ๊ธฐ์„œ display: flex๋ฅผ ๋„ฃ๋Š”๋‹ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์ •๋ ฌ๋œ๋‹ค.
ย 
notion imagenotion image
.container { display: flex; }
<body> <div class="container"> <div class="item">1</div> <div class="item even">2</div> <div class="item">3</div> <div class="item even">4</div> <div class="item">5</div> </div> </body>
์ž์‹์š”์†Œ(์•„์ดํ…œ)๋“ค์ด ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์— ๋งž๊ฒŒ ์ •๋ ฌ๋œ ๋ชจ์Šต์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ์ด๋ ‡๊ฒŒ flex๋Š” ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ ๊ณต๊ฐ„์— ๋งž๊ฒŒ ์ž์‹์š”์†Œ(์•„์ดํ…œ)๋“ค์˜ ํฌ๊ธฐ๋‚˜ ์ •๋ ฌ์„ ๋งž์ถฐ์ฃผ๋Š” ์†์„ฑ์ด๋‹ค. display์˜ ๋Œ€ํ‘œ์ ์ธ ์†์„ฑ ๊ฐ’์€ grid, block, inline, line-block์ด๋‹ค.

2. Flex-direction

flex-direction ์ด๋ž€ flex container ๋‚ด์˜ item๋“ค์˜ ์ •๋ ฌ ๋ฐฉํ–ฅ์„ ๊ฒฐ์ •ํ•˜๋Š” ์†์„ฑ์ด๋‹ค. flex-direction์€ ์ž์‹์š”์†Œ(์•„์ดํ…œ)์˜ ๋ถ€๋ชจ์š”์†Œ์ธ (์ปจํ…Œ์ด๋„ˆ)์— ์ ์šฉํ•˜์—ฌ ์‚ฌ์šฉํ•˜๋ฉฐ ์ข…๋ฅ˜๋Š” row, row-reverse, column, column-reverse ๋„ค ๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค.

2.1. flex-direction : row

์™ผ์ชฝ์—์„œ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ๊ธ€์”จ๊ฐ€ ์จ์ง€๋Š” ํ–‰ ๋ฐฉํ–ฅ ์ •๋ ฌ์ด๋ฉฐ, flex-direction์„ ๋”ฐ๋กœ ์„ค์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ์ดˆ๊นƒ๊ฐ’์œผ๋กœ ์„ค์ •๋œ๋‹ค.
notion imagenotion image
.container { display: flex; flex-direction: row; }

2.2. flex-direction : row-reverse

row์™€ ๋™์ผํ•˜๊ฒŒ ๋ณด์—ฌ์ง€์ง€๋งŒ ์‹œ์ž‘์ ๊ณผ ๋์ ์ด ๋ฐ˜๋Œ€๋กœ ์œ„์น˜ํ•œ๋‹ค.
notion imagenotion image
.container { display: flex; flex-direction: row-reverse; }
์ปจํ…Œ์ด๋„ˆ ๋‚ด์— ์œ„์น˜ํ•œ ์•„์ดํ…œ๋“ค์„ ์œ ์—ฐํ•˜๊ฒŒ ์ •๋ ฌ ํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์—ญ์ˆœ์œผ๋กœ ์ •๋ ฌํ•œ๋‹ค. ์ปจํ…Œ์ด๋„ˆ์—๊ฒŒ display: flex ์†์„ฑ์„ ๋ถ€์—ฌํ•˜์ง€ ์•Š์œผ๋ฉด ์•„์ดํ…œ์€ ์œ ์—ฐํ•˜๊ฒŒ ์›€์ง์ด์ง€ ์•Š๋Š”๋‹ค.

2.3. flex-direction : column

Flex ๋‚ด box๋“ค์„ ์ˆ˜์ง์œผ๋กœ ์ •๋ ฌํ•œ๋‹ค. ์ปจํ…Œ์ด๋„ˆ ๋‚ด๋ถ€์˜ ์š”์†Œ๋“ค์ด ์•„์ดํ…œ์ด ์•„๋‹Œ ๊ฒฝ์šฐ ํ•ด๋‹น ์†์„ฑ์˜ ๊ฐ’์€ ์ ์šฉ๋˜์ง€ ์•Š๋Š”๋‹ค. flex-direction : column;์ผ ๋•Œ ์ฃผ์ถ•์€ ์„ธ๋กœ ๋ฐฉํ–ฅ์ด ๋˜๊ณ , ๊ต์ฐจ ์ถ•์€ ๊ฐ€๋กœ ๋ฐฉํ–ฅ์ด ๋œ๋‹ค. ์•„์ดํ…œ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒฝ์šฐ ๋งˆํฌ์—… ์ˆœ์„œ์— ๋งž๊ฒŒ ์œ„์—์„œ ์•„๋ž˜๋กœ ํ๋ฅด๋“ฏ์ด ์ •๋ ฌ๋œ๋‹ค.
notion imagenotion image
.container{ display : flex; flex-direction : column; }

2.4. flex-direction : column-reverse

column ๊ณผ ๋™์ผํ•˜๊ฒŒ ๋ณด์—ฌ์ง€์ง€๋งŒ ์‹œ์ž‘ ์ ๊ณผ ๋ ์ ์ด ๋ฐ˜๋Œ€๋กœ ์œ„์น˜ํ•œ๋‹ค.
notion imagenotion image
.container{ display : flex; flex-direction : column-reverse; }

3. Justify-content

justify-content๋Š” main-axis๋กœ ์–ด๋–ป๊ฒŒ ์ •๋ ฌํ• ์ง€ ์ •ํ•˜๋Š” ์ฝ”๋“œ์ด๋‹ค.

3.1. flex-start

๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์— display: flex, justify-content: flex-start ๊ฐ’์„ ์ฃผ๋ฉด ๋œ๋‹ค.
.container { display: flex; justify-content: flex-start; }
justify-content: flex-start;๋Š” ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ Flex ์•„์ดํ…œ๋“ค์„ ์‹œ์ž‘์ ์„ ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌํ•œ๋‹ค. ๊ธฐ๋ณธ๊ฐ’์ผ ๋•Œ, ๊ธฐ์ค€์ด ๋˜๋Š” ์ ์€ ์™ผ์ชฝ ์ถ•์˜ ์ƒ๋‹จ์ด๋‹ค.
ย 
flex-direction: row;์ธ ๊ฒฝ์šฐ์—๋Š” ๊ฐ€๋กœ(row=ํ–‰)๋กœ ์ •๋ ฌ ํ•˜๋ฉฐ ์™ผ์ชฝ ์ƒ๋‹จ์ด ๊ธฐ์ค€์ ์ด ๋˜์–ด์„œ ์™ผ์ชฝ ์ƒ๋‹จ๋ถ€ํ„ฐ ์ฐจ๋ก€๋Œ€๋กœ 1, 2, 3๋ฒˆ ์ˆœ์œผ๋กœ ์•„์ดํ…œ์ด ๋ฐฐ์น˜๋œ๋‹ค.
notion imagenotion image
๊ทธ๋ ‡์ง€๋งŒ flex-direction: column;์„ ์ค€ ๊ฒฝ์šฐ์—๋Š”, ์ปจํ…Œ์ด๋„ˆ์˜ ์ƒ๋‹จ์ด ๊ธฐ์ค€์ ์ธ ๊ฒƒ์€ ๊ฐ™์ง€๋งŒ flex ๋ฐฉํ–ฅ์ด row(ํ–‰)๊ฐ€ ์•„๋‹Œ column(์—ด)์ด๊ธฐ ๋•Œ๋ฌธ์— ์„ธ๋กœ(์—ด)๋กœ ์•„์ดํ…œ์ด ๋ฐฐ์น˜๋œ๋‹ค.
notion imagenotion image
.container { display: flex; justify-content: flex-start; flex:-direction: column; }

3.2. flex-end

๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์— display: flex;, justify-content: flex-end; ๊ฐ’์„ ์ฃผ๋ฉด ๋œ๋‹ค.
.container { display: flex; justify-content: flex-end; }
justify-content: flex-end;๋Š” ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)๋ฅผ ๋งจ ๋์ ์œผ๋กœ ๋ฐฐ์น˜ํ•˜๋Š”๋ฐ, ๊ธฐ๋ณธ๊ฐ’(์™ผ์ชฝ ์ถ•)์˜ ๋ฐ˜๋Œ€์ธ ์˜ค๋ฅธ์ชฝ ์ถ•์˜ ์ƒ๋‹จ์ด ๊ธฐ์ค€์ด ๋œ๋‹ค.
flex-direction: row;์ธ ๊ฒฝ์šฐ์ผ ๋•Œ์—๋Š” row(ํ–‰)๋กœ ์ •๋ ฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)์ธ 1, 2, 3๋ฒˆ์˜ ์•„์ดํ…œ๋“ค์ด ์˜ค๋ฅธ์ชฝ ์ถ•์— ๋ถ™์–ด ๋ฐฐ์น˜๋œ๋‹ค.
notion imagenotion image
flex-direction: column; ์„ ์ค€ ๊ฒฝ์šฐ์—๋Š”, flex ๋ฐฉํ–ฅ์ด row(ํ–‰)๊ฐ€ ์•„๋‹Œ column(์—ด)์ด ๋˜๊ธฐ ๋•Œ๋ฌธ์— ์„ธ๋กœ(์—ด)๋กœ ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)๊ฐ€ ๋ฐฐ์น˜๋œ๋‹ค.
๊ทธ๋ฆฌ๊ณ  justify-content: flex-end; ์˜ ๊ฒฝ์šฐ, ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)๋ฅผ ๋ฐฐ์น˜ํ•˜๋Š” ๊ธฐ์ค€์ด ๊ธฐ๋ณธ๊ฐ’(์ƒ๋‹จ ์ถ•)์˜ ๋ฐ˜๋Œ€์ธ ํ•˜๋‹จ ์ถ•์ด ๋˜๊ธฐ ๋•Œ๋ฌธ์— 1, 2, 3๋ฒˆ์˜ ์•„์ดํ…œ์ด ์„ธ๋กœ๋กœ ์ •๋ ฌ๋˜์–ด ํ•˜๋‹จ์— ๋ถ™์–ด ๋ฐฐ์น˜๋œ๋‹ค.
notion imagenotion image
.container { display: flex; justify-content: flex-end; flex-direction: column; }

3.3. center

justify-content: center๋ฅผ ์ค€ ๊ฒฝ์šฐ, Flex-box ๋‚ด์˜ ์š”์†Œ๋“ค์„ ์ฃผ์ถ•(main-axis)์˜ ์ค‘์•™์„ ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌํ•œ๋‹ค. ์ฆ‰, ์š”์†Œ๋“ค์„ ๊ฐ€์šด๋ฐ ์ •๋ ฌํ•ด์ค€๋‹ค. ์ด๋•Œ ์š”์†Œ์˜ ๊ฐ„๊ฒฉ์€ ๊ท ๋“ฑ ๋ถ„ํ• ๋œ๋‹ค. ๊ฐœ๋ณ„์ ์œผ๋กœ ๋นˆ ๊ณต๊ฐ„์„ ์ œ์–ดํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ํ•ด๋‹น ์š”์†Œ์— ๋ณ„๋„์˜ margin ๊ฐ’์„ ์ฃผ์–ด์•ผ ํ•œ๋‹ค. space-between,ย space-around ์—ญ์‹œ ๋™์ผํ•˜๋‹ค.
.container { display: flex; justify-content: center; }
notion imagenotion image
.container { display: flex; justify-content: center; align-items:center; }
notion imagenotion image
.container { display: flex; flex-direction:column; justify-content: center; align-items:center; }

3.4. space-between, space-around, space-evenly

๋‹ค์Œ์œผ๋กœ space-between, space-around, space-evenly์˜ ๋น„์Šทํ•˜๋ฉด์„œ๋„ ๋‹ค๋ฅธ ์ ๋“ค์„ ์•Œ์•„๋ณด์ž. ์œ„ ์…‹์˜ ๊ณตํ†ต์ ์€ ์ž์‹ ์š”์†Œ๋“ค์„ ๋ฉ”์ธ ์ถ•์œผ๋กœ ์ •๋ ฌํ•˜๋ฉฐ, ์ผ์ •ํ•œ ๊ฐ„๊ฒฉ์„ ์ค€๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. between, around, evenly์˜ ๋œป์€ ์ฐจ๋ก€๋กœ โ€˜์‚ฌ์ด์—โ€™, โ€˜๋‘˜๋ ˆ์—โ€™, โ€˜๊ท ๋“ฑํ•˜๊ฒŒโ€™๋ผ๋Š” ๋œป์ด๋‹ค. ๊ทธ๋Ÿผ ๋œป์„ ์ƒ๊ฐํ•˜๋ฉฐ ์•„๋ž˜ ๊ทธ๋ฆผ์œผ๋กœ ์ฐจ์ด์ ์„ ํ™•์ธํ•ด ๋ณด์ž.
notion imagenotion image
.container { display: flex; justify-content: flex-start; }
์•„๋ฌด ์ •๋ ฌ๋„ ์ง€์ •ํ•ด์ฃผ์ง€ ์•Š์•˜์„ ๋•Œ์˜ ๊ธฐ๋ณธ๊ฐ’์ด๋‹ค.

3.4.1. space-between

notion imagenotion image
.container { display: flex; justify-content: space-between; }
justify-content: space-between;์„ ์ฃผ์—ˆ์„ ๋•Œ ์ž์‹ ์š”์†Œ๋“ค์˜ โ€˜์‚ฌ์ด์—' ๊ฐ™์€ ๊ฐ„๊ฒฉ์ด ๋“ค์–ด๊ฐ„ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ์ปจํ…Œ์ด๋„ˆ์˜ ํŒจ๋”ฉ ๊ฐ’์„ ์ œ์™ธํ•˜๋ฉด ์ปจํ…Œ์ด๋„ˆ์˜ ๋„ˆ๋น„์— ๊ฝ‰ ์ฐจ๊ฒŒ ๋ฐฐ์น˜๋œ๋‹ค.

3.4.2. space-around

notion imagenotion image
.container { display: flex; justify-content: space-around; }
์•„์ดํ…œ์˜ โ€˜๋‘˜๋ ˆ์—' ๊ฐ™์€ ๊ฐ„๊ฒฉ์ด ๋“ค์–ด๊ฐ„ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ์•„์ดํ…œ ์‚ฌ์ด์—๋Š” ๊ฐ™์€ ๊ฐ„๊ฒฉ์ด 2๋ฒˆ์”ฉ ๋“ค์–ด๊ฐ€๊ฒŒ ๋˜๋ฏ€๋กœ ์–‘ ๋ ์ปจํ…Œ์ด๋„ˆ ์‚ฌ์ด์˜ ๊ฐ„๊ฒฉ์€ ์•„์ดํ…œ ์‚ฌ์ด์˜ ๊ฐ„๊ฒฉ์˜ 1/2์ด ๋œ๋‹ค.

3.4.3. space-evenly

notion imagenotion image
.container { display: flex; justify-content: space-evenly; }
๋ชจ๋“  ๊ฐ„๊ฒฉ์ด โ€˜๊ท ๋“ฑํ•˜๊ฒŒ' ๋ฐฐ์น˜๋œ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. space-around์™€ ๋น„์Šทํ•˜๊ฒŒ ๋ณด์ด์ง€๋งŒ ์–‘ ๋์˜ ๊ฐ„๊ฒฉ๊ณผ ์ž์‹ ์š”์†Œ ์‚ฌ์ด์˜ ๊ฐ„๊ฒฉ์ด ๊ฐ™์€ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

3.5. ์ž์ฃผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ์†์„ฑ๋“ค

3.5.1. justify-content : normal

๊ฐ’์ด ์„ค์ •๋˜์ง€ ์•Š์€ ๊ฒƒ์ฒ˜๋Ÿผ ๊ธฐ๋ณธ ์œ„์น˜์— ์ •๋ ฌํ•œ๋‹ค. ๊ธฐ๋ณธ๊ฐ’์ด๋ฏ€๋กœ ์ƒ๋žต ํ•  ์ˆ˜ ์žˆ๋‹ค.
notion imagenotion image
.container { display: flex; justify-content: normal; align-items: flex-start; }

3.5.2. justify-content : initial

๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ์ •๋ ฌํ•œ๋‹ค. justify-content์˜ ๊ธฐ๋ณธ๊ฐ’์€ normal์ด๋ฏ€๋กœ ์œ„์˜ justify-content:normal๊ณผ ๊ฒฐ๊ณผ๊ฐ€ ๋™์ผํ•˜๊ฒŒ ๋‚˜์˜จ๋‹ค.
notion imagenotion image
.container { display: flex; justify-content: initial; align-items: flex-start; }

3.5.3. justify-content : inherit

์ƒ์†๋˜๋Š” ๊ฐ’์— ๋”ฐ๋ผ ์ •๋ ฌํ•œ๋‹ค. container์— class ๋ช…์ด โ€œwrap-containerโ€์ธ ๋ถ€๋ชจ ์š”์†Œ๋ฅผ ๋งŒ๋“ค์–ด ์ฃผ์—ˆ๋‹ค. wrap-container์˜ justify-content:center ์†์„ฑ์ด ์ƒ์†๋˜์–ด ์ž์‹ ์š”์†Œ์ธ container์˜ justify-content๋„ center๋กœ ์ ์šฉ๋œ๋‹ค.
notion imagenotion image
.wrap-container { display: flex; justify-content: center; } .container { display: flex; justify-content: inherit; }
<body> <div class="wrap-container"> <div class="container"> <div class="item">1</div> <div class="item even">2</div> <div class="item">3</div> </div> </div> </body>

3.5.4. justify-content : revert

์ƒ์†๋œ ์†์„ฑ์œผ๋กœ๋ถ€ํ„ฐ ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ๋˜๋Œ๋ฆฐ๋‹ค. ํŠน์ • ์‚ฌ์ดํŠธ๋งŒ์˜ css ์†์„ฑ์ด ์ง€์ •๋˜์–ด ์žˆ๊ฑฐ๋‚˜ ์‚ฌ์šฉ์ž๊ฐ€ ์ •์˜ํ•œ ์Šคํƒ€์ผ์ด ์ ์šฉ๋œ ์†์„ฑ์„ ๋ถ€๋ชจ ์†์„ฑ ๋˜๋Š” ์‚ฌ์šฉ์ž ์—์ด์ „ํŠธ์˜ ๊ธฐ๋ณธ ์Šคํƒ€์ผ๋กœ ๋˜๋Œ๋ฆฐ๋‹ค. ์‚ฌ์šฉ์ž ์—์ด์ „ํŠธ๋ž€ ๋ธŒ๋ผ์šฐ์ €๋งˆ๋‹ค ์ •ํ•ด๋†“์€ css ๊ธฐ๋ณธ ๊ทœ์น™์ด๋‹ค.

3.5.5. justify-content : unset

๋ถ€๋ชจ ์š”์†Œ๋กœ๋ถ€ํ„ฐ ์ƒ์†๋ฐ›๋Š” ๊ฐ’์ด ์žˆ์œผ๋ฉด inherit๋กœ ์ ์šฉ๋˜๊ณ  ์ƒ์†๋˜๋Š” ๊ฐ’์ด ์—†๋‹ค๋ฉด initial ์†์„ฑ์œผ๋กœ ์ •๋ ฌํ•œ๋‹ค.

3.5.6. firefox์—์„œ๋งŒ ์ง€์›ํ•˜๋Š” ์†์„ฑ

justify-content: revert-layer;
์ด์ „ ๋ ˆ์ด์–ด์— ์ง€์ •๋œ ์Šคํƒ€์ผ๋กœ ๋˜๋Œ๋ฆด ์ˆ˜ ์žˆ๋‹ค. revert์™€ ๋‹ฌ๋ฆฌ ์ž‘์„ฑ์ž ์›๋ณธ์— ์ ์šฉ๋œ ์Šคํƒ€์ผ์„ ์ œ๊ฑฐํ•˜๊ณ  ์‚ฌ์šฉ์ž ์›๋ณธ ๋˜๋Š” ์‚ฌ์šฉ์ž ์—์ด์ „ํŠธ์˜ ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ๋˜๋Œ๋ฆฐ๋‹ค.
justify-content: safe;
๋‹ค๋ฅธ ์ •๋ ฌ ์†์„ฑ๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉ๋œ๋‹ค. ํ•ญ๋ชฉ์ด ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์˜ค๋ฒ„ํ”Œ๋กœ ํ•˜์—ฌ ๋ฐ์ดํ„ฐ๊ฐ€ ์†์‹ค๋œ๋‹ค๋ฉด ํ•ญ๋ชฉ์ด start ์†์„ฑ์ฒ˜๋Ÿผ ์ •๋ ฌ๋œ๋‹ค.
justify-content: unsafe;
๋‹ค๋ฅธ ์ •๋ ฌ ์†์„ฑ๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉ๋œ๋‹ค. ์ปจํ…Œ์ด๋„ˆ์˜ ์ƒ๋Œ€์  ํฌ๊ธฐ์™€ ๊ด€๊ณ„์—†์ด, ๋ฐ์ดํ„ฐ ์†์‹ค์„ ์ผ์œผํ‚ค๋Š” ์˜ค๋ฒ„ํ”Œ๋กœ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š”์ง€์™€ ๊ด€๊ณ„์—†์ด ์ง€์ •๋œ ์ •๋ ฌ ๊ฐ’์ด ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.

4. Align-items, Align-content

4.1. align-items

align์˜ ์‚ฌ์ „์  ์ •์˜๋Š” โ€˜์ผ์ง์„ ์œผ๋กœ ๋งž์ถ”๋‹คโ€™์ด๋‹ค. ์ฆ‰, flex์—์„œ align์ด๋ž€ ์ถ•์˜ ์ˆ˜์ง ๋ฐฉํ–ฅ ์ •๋ ฌ์„ ์˜๋ฏธํ•˜๋ฉฐ, ๋ถ€๋ชจ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ) ์•ˆ์—์„œ ๊ต์ฐจ ์ถ•์— ๋”ฐ๋ผ ์ž์‹์š”์†Œ(์•„์ดํ…œ)๊ฐ€ ์ •๋ ฌ๋˜๋Š” ์†์„ฑ์ด๋‹ค.
ย 
์†์„ฑ
  • stretch
align-items์˜ ๊ธฐ๋ณธ๊ฐ’์ด๋‹ค. ๋ถ€๋ชจ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ ๋†’์ด๋งŒํผ ์ž์‹์š”์†Œ(์•„์ดํ…œ) ๋†’์ด๊ฐ€ ๊ฐ™์ด ๋Š˜์–ด๋‚œ๋‹ค.
notion imagenotion image
.container { display: flex; align-items: stretch; }
ย 
  • flex-start
์ž์‹์š”์†Œ(์•„์ดํ…œ)๋Š” ๊ต์ฐจ ์ถ• ์‹œ์ž‘์ ์—์„œ ์ •๋ ฌ๋œ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ ๊ฐ€๋กœ์ถ•์€ ์ˆ˜์ง์„ ์˜๋ฏธํ•˜๋ฉฐ, ์ž์‹์š”์†Œ(์•„์ดํ…œ)๋Š” ์ƒ๋‹จ์—์„œ ์ˆ˜์ง์œผ๋กœ ์ •๋ ฌ๋œ๋‹ค.
notion imagenotion image
.container { display: flex; align-items: flex-start; }
ย 
  • flex-end
์ž์‹์š”์†Œ(์•„์ดํ…œ)๋Š” ๊ต์ฐจ ์ถ• ๋์ ์—์„œ ์ •๋ ฌ๋œ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ ๊ฐ€๋กœ์ถ•์€ ์ˆ˜์ง์„ ์˜๋ฏธํ•˜๋ฉฐ, ์ž์‹์š”์†Œ(์•„์ดํ…œ)๋Š” ํ•˜๋‹จ์—์„œ ์ˆ˜์ง์œผ๋กœ ์ •๋ ฌ๋œ๋‹ค.
notion imagenotion image
.container { display: flex; align-items: flex-end; }
ย 
  • center
์ž์‹์š”์†Œ(์•„์ดํ…œ)๋Š” ๊ต์ฐจ ์ถ• ์ค‘์•™์œผ๋กœ ์ •๋ ฌ๋œ๋‹ค.
notion imagenotion image
.container { display: flex; align-items: center; }
ย 
  • baseline
์ž์‹์š”์†Œ(์•„์ดํ…œ)๋Š” ๊ต์ฐจ ์ถ•์˜ ๊ธฐ์ค€์„ ์— ์ •๋ ฌ์ด ๋œ๋‹ค. ํ…์ŠคํŠธ์˜ ๊ธฐ์ค€์„ ์ด ์ˆ˜ํ‰์„ ์„ ๋”ฐ๋ผ ์•„์ดํ…œ์ด ์ •๋ ฌ๋œ๋‹ค.
notion imagenotion image
.container { display: flex; align-items: baseline; }
ย 
3. align-self์™€ ๋‹ค๋ฅธ ์ ์€?
align-items๋Š” ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ) ๋‚ด์— ์žˆ๋Š” ์ž์‹ ์š”์†Œ๋ฅผ ๋Œ€์ƒ์œผ๋กœ ์ ์šฉํ•˜๋Š” ๋ฐ˜๋ฉด์—, align-self๋Š” ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ) ์•ˆ์—์„œ ํŠน์ • ์•„์ดํ…œ๋งŒ ๊ต์ฐจ ์ถ•์œผ๋กœ ์ •๋ ฌ๋œ๋‹ค. ์ฆ‰, ํŠน์ • ์•„์ดํ…œ์˜ ์ •๋ ฌ์„ ๋”ฐ๋กœ ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ์ด ์†์„ฑ์„ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.
notion imagenotion image
.container { display: flex; align-items: flex-start; } .third_item { align-self: center; }
ํ”Œ๋ ‰์Šค ๋ฐ•์Šค ์ปจํ…Œ์ด๋„ˆ์— align-items : flex-start๋ฅผ ์ ์šฉํ•˜๊ณ  โ€˜third_itemโ€™ ์ด๋ฆ„์„ ๊ฐ€์ง„ ํŠน์ • ์•„์ดํ…œ๋งŒ align-self : center๋ฅผ ์ ์šฉํ–ˆ๋‹ค. ์œ„์™€ ๊ฐ™์ด 3๋ฒˆ ์•„์ดํ…œ๋งŒ ์ค‘์•™์ •๋ ฌ ์†์„ฑ์ด ์ ์šฉ๋˜๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

4.2. align-content

align-items๋Š” ํ•œ ์ค„์„ ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌํ•˜์ง€๋งŒ, align-content๋Š” flex-wrap : wrap; ์ด ์„ค์ •๋œ ๊ฒฝ์šฐ ๋‘ ์ค„๋ถ€ํ„ฐ ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌํ•œ๋‹ค. ์•„๋ž˜ ์˜ˆ์‹œ๋ฅผ ๋ณด๋ฉด, ๋” ์‰ฝ๊ฒŒ ์•Œ ์ˆ˜ ์žˆ๋‹ค.
notion imagenotion image
notion imagenotion image
์ขŒ์ธก์€ align-items : center; , ์šฐ์ธก์€ align-content : center; ๋กœ ์ •๋ ฌํ•œ ๊ฒฐ๊ณผํ™”๋ฉด์ด๋‹ค. align-items๋Š” ์•„์ดํ…œ ํ•œ ์ค„๋งˆ๋‹ค ์†์„ฑ์ด ์ ์šฉ๋˜์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ๋‘ ์ค„ ์‚ฌ์ด์— ๊ฐ„๊ฒฉ์ด ์ƒ๊ฒจ ์ •๋ ฌ๋œ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ๋ฐ˜๋ฉด์—, align-content๋Š” ๋‘ ์ค„ ์ด์ƒ์˜ ์•„์ดํ…œ์„ ์ˆ˜์ง์ถ• ๋ฐฉํ–ฅ์œผ๋กœ ๋ผ์ธ ์ž์ฒด๋ฅผ ์ •๋ ฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋‘ ์ค„ ์‚ฌ์ด์— ๊ฐ„๊ฒฉ์ด ์ƒ๊ธฐ์ง€ ์•Š์€ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.
ย 
์†์„ฑ
  • stretch
๋ถ€๋ชจ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ ๋†’์ด๋งŒํผ ์ž์‹์š”์†Œ(์•„์ดํ…œ) ๋†’์ด๊ฐ€ ๊ฐ™์ด ๋Š˜์–ด๋‚œ๋‹ค.
notion imagenotion image
.container { display: flex; flex-wrap: wrap; align-content: stretch; }
ย 
  • flex-start
๋ถ€๋ชจ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ ์ตœ์ƒ๋‹จ์—์„œ๋ถ€ํ„ฐ ์ •๋ ฌ์„ ์‹œ์ž‘ํ•œ๋‹ค.
notion imagenotion image
.container { display: flex; flex-wrap: wrap; align-content: flex-start; }
ย 
  • flex-end
๋ถ€๋ชจ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ ์ตœํ•˜๋‹จ์—์„œ๋ถ€ํ„ฐ ์ •๋ ฌ์„ ์‹œ์ž‘ํ•œ๋‹ค.
notion imagenotion image
.container { display: flex; flex-wrap: wrap; align-content: flex-end; }
ย 
  • center
๋ถ€๋ชจ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ) ๊ต์ฐจ ์ถ•์˜ ์ค‘์•™์— ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค.
notion imagenotion image
.container { display: flex; flex-wrap: wrap; align-content: center; }
ย 
  • space-between
๋ถ€๋ชจ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ) ๊ต์ฐจ ์ถ•์˜ ์–‘ ๋(์‹œ์ž‘์ , ์ข…๋ฃŒ์ )์— ๋งž์ถฐ ์•„์ดํ…œ ๊ฐ„์— ์ผ์ •ํ•œ ๊ฐ„๊ฒฉ์„ ๋‘๊ณ  ์ •๋ ฌํ•œ๋‹ค.
notion imagenotion image
.container { display: flex; flex-wrap: wrap; align-content: space-between; }
ย 
  • space-around
space-between๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ๋ถ€๋ชจ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ) ๊ต์ฐจ ์ถ•์˜ ์–‘ ๋(์‹œ์ž‘์ , ์ข…๋ฃŒ์ )์— ๋งž์ถฐ ์•„์ดํ…œ ๊ฐ„์— ์ผ์ •ํ•œ ๊ฐ„๊ฒฉ์„ ๋‘๊ณ  ์ •๋ ฌํ•œ๋‹ค. ์ด๋•Œ ์ฒซ ์•„์ดํ…œ ์•ž ์—ฌ๋ฐฑ๊ณผ ๋งˆ์ง€๋ง‰ ์•„์ดํ…œ ๋’ค ์—ฌ๋ฐฑ์€ ๊ฐ ์•„์ดํ…œ ๊ฐ„ ๊ฑฐ๋ฆฌ์˜ ์ ˆ๋ฐ˜ ํฌ๊ธฐ๋ฅผ ์ฐจ์ง€ํ•˜์—ฌ ์ •๋ ฌ๋œ๋‹ค.
notion imagenotion image
.container { display: flex; flex-wrap: wrap; align-content: space-around; }
  • space-evenly
space-between๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ) ๊ต์ฐจ ์ถ•์˜ ์–‘ ๋(์‹œ์ž‘์ , ์ข…๋ฃŒ์ )์— ๋งž์ถฐ ์•„์ดํ…œ ๊ฐ„์— ์ผ์ •ํ•œ ๊ฐ„๊ฒฉ์„ ๋‘๊ณ  ์ •๋ ฌํ•œ๋‹ค. ์ด๋•Œ ์•„์ดํ…œ ๊ฐ„์˜ ๊ฑฐ๋ฆฌ, ์ฒซ ์•„์ดํ…œ ์•ž ์—ฌ๋ฐฑ๊ณผ ๋งˆ์ง€๋ง‰ ์•„์ดํ…œ ๋’ค ์—ฌ๋ฐฑ์˜ ํฌ๊ธฐ๊ฐ€ ๋ชจ๋‘ ๋™์ผํ•˜๊ฒŒ ์ •๋ ฌ๋œ๋‹ค. ๋ณธ ์†์„ฑ์€ IE, Edge์—์„œ๋Š” ์ง€์›๋˜์ง€ ์•Š๋Š”๋‹ค.
notion imagenotion image
.container { display: flex; flex-wrap: wrap; align-content: space-evenly; }

5. Flex-wrap

์›นํŽ˜์ด์ง€ ๋ ˆ์ด์•„์›ƒ์„ ๊ตฌ์„ฑํ•  ๋•Œ ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ) ์•ˆ์˜ ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)๋“ค์ด ๋งŽ์œผ๋ฉด ๊ณ ๋ฏผํ•  ๋•Œ๊ฐ€ ์žˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์˜์–ด ๋‹จ์–ด ์›นํŽ˜์ด์ง€๋ฅผ ๋งŒ๋“ ๋‹ค๊ณ  ๊ฐ€์ •ํ•ด๋ณด์ž. ๋‹จ์–ด ์นด๋“œ๋“ค์„ ํ•œ ์ค„์— ๊ธธ๊ฒŒ ๋ฐฐ์น˜ํ•  ๊ฒƒ์ธ์ง€ ์•„๋‹ˆ๋ฉด ํ•œ ์ค„์ด ์•„๋‹Œ ๋‘ ์ค„ ์ด์ƒ์œผ๋กœ ๋ฐฐ์น˜ํ• ์ง€ ๊ณ ๋ฏผ์ด ๋“ค ๋•Œ๊ฐ€ ์žˆ๋‹ค.
no-wrapno-wrap
no-wrap
wrapwrap
wrap
wrap-reversewrap-reverse
wrap-reverse
.container { display: flex; /* flex-wrap: nowrap; */ /* flex-wrap: wrap; */ /* flex-wrap: wrap-reverse; */ }
<body> <div class="container"> <div class="item">Cat</div> <div class="item even">Mouse</div> <div class="item">Dog</div> <div class="item even">Tiger</div> <div class="item">Monkey</div> <div class="item even">Rabbit</div> </div> </body>
flex-wrap ์†์„ฑ์„ ์‚ฌ์šฉํ•˜๊ฒŒ ๋˜๋ฉด, ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ ํฌ๊ธฐ๋งŒํผ ๋‹จ์–ด ์นด๋“œ๋“ค์˜ ํฌ๊ธฐ๋ฅผ ์กฐ์ ˆํ•  ์ˆ˜๋„ ์žˆ๊ณ , ๋‹จ์–ด ์นด๋“œ๋“ค์˜ ํฌ๊ธฐ๋งŒํผ ์˜์—ญ์„ ์ฐจ์ง€ํ•˜๊ณ  ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ ์˜์—ญ์„ ๋ฒ—์–ด๋‚˜๊ฒŒ ๋˜๋ฉด ๋‹จ์–ด ์นด๋“œ๋ฅผ ๋ฐ‘์œผ๋กœ ๋‚ด๋ ค์„œ ์ •๋ ฌ๋„ ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋œ๋‹ค.
flex-wrap ์†์„ฑ์€ Flex ๋ ˆ์ด์•„์›ƒ ๋ชจ๋“ˆ์˜ ํ•˜์œ„ ์†์„ฑ์ด๋‹ค. ์ •๋ ฌ๋œ ์š”์†Œ๋“ค์˜ ์ด ๋„ˆ๋น„๊ฐ€ ๋ถ€๋ชจ ๋„ˆ๋น„๋ณด๋‹ค ํด ๋•Œ, ์š”์†Œ๋“ค์„ ๊ฐ•์ œ์ ์œผ๋กœ ํ•œ ์ค„๋กœ ํ•  ๊ฒƒ์ธ์ง€ ์—ฌ๋Ÿฌ ์ค„๋กœ ํ•  ๊ฒƒ์ธ์ง€๋ฅผ ์ •์˜ํ•œ๋‹ค. ๋‘ ์ค„ ์ด์ƒ์ธ ๊ฒฝ์šฐ ์ƒˆ๋กœ์šด ๋ผ์ธ์ด ์Œ“์ผ ๋ฐฉํ–ฅ์„ ๊ฒฐ์ •ํ•˜๋Š” ๊ต์ฐจ ์ถ•๋„ ์ •์˜๋œ๋‹ค. ๊ฐ€๋กœ์ถ•์€ ๋ฉ”์ธ์ถ•์— ์ˆ˜์ง์ธ ์ถ•์ด๋‹ค. ๋ถ€๋ชจ ์š”์†Œ์— display:flex;๋ฅผ ๊ผญ ์ž‘์„ฑํ•ด์•ผํ•œ๋‹ค.

5.1. flex-wrap : nowrap

flex-wrap ์†์„ฑ ์ค‘ย nowrap์˜ย ์†์„ฑ์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด์ž. flex-wrap๋Š” ์ž‘์„ฑ์ž๊ฐ€ ๋”ฐ๋กœย ์„ค์ •ํ•˜์ง€ย ์•Š๋Š”๋‹ค๋ฉด ๊ธฐ๋ณธ๊ฐ’์ธย nowrap์œผ๋กœ ์„ค์ •๋œ๋‹ค. flex-wrap:ย nowrap์„ย ์‚ฌ์šฉํ•˜์˜€์„ ๋•Œ, ์•„๋ž˜ ๊ทธ๋ฆผ๊ณผ ๊ฐ™์ดย ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)์˜ย ํฌ๊ธฐ๊ฐ€ย ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ย ํฌ๊ธฐ์— ๋งž์ถฐ ์ผ์ • ๋น„์œจ๋งŒํผ ์ค„์–ด๋“œ๋Š” ๊ฒƒ์„ย ํ™•์ธํ• ย ์ˆ˜ ์žˆ์„ ๊ฒƒ์ด๋‹ค.
notion imagenotion image
ํ•˜์ง€๋งŒ, ๊ฒ€์ƒ‰์„ ํ†ตํ•ด์„œ wrap์˜ ์†์„ฑ์„ย ์ฐพ์•„๋ดค๋‹ค๋ฉด, ์•„๋ž˜ ๊ทธ๋ฆผ์ฒ˜๋Ÿผ ๋ถ€๋ชจ์˜์—ญ(์ปจํ…Œ์ด๋„ˆ)์„ ๋„˜์–ด๊ฐ€๋Š” ๊ทธ๋ฆผ์„ ๋ณด์•˜์„ ๊ฒƒ์ด๋‹ค. ์ด๋ ‡๊ฒŒ ๋˜๋Š” ์ด์œ ๋Š” 8์žฅ์—์„œ ๋‹ค๋ฃจ๊ฒŒ ๋  flex-shrink์˜ ์†์„ฑ ๋•Œ๋ฌธ์ด๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ flex-shrink์˜ย ์ดˆ๊นƒ๊ฐ’์€ย 1๋กœย ์„ค์ •๋˜์–ด์žˆ์–ด์„œย ์ผ์ • ๋น„์œจ๋งŒํผ ์ค„์–ด๋“ค๊ฒŒ ๋˜๋Š”๋ฐ ์ด ์†์„ฑ์„ 0์œผ๋กœ ํ•˜๋ฉด ์•„๋ž˜ ๊ทธ๋ฆผ์ฒ˜๋Ÿผ ๋ถ€๋ชจ์˜์—ญ(์ปจํ…Œ์ด๋„ˆ)์„ ๋„˜์–ด๊ฐ€๊ฒŒ ๋œ๋‹ค.
๋”ฐ๋ผ์„œ flex-wrap :ย nowrap์€ย ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)์˜ ์ „์ฒด ํฌ๊ธฐ๊ฐ€ ๋ถ€๋ชจ์˜์—ญ(์ปจํ…Œ์ด๋„ˆ)์„ ๋„˜์–ด๊ฐ€์ง€ ์•Š๋Š”๋‹ค๋ฉด ์ž๊ธฐ ์ž์‹ ์˜ ํฌ๊ธฐ๋ฅผ ์œ ์ง€ํ•˜๊ฒŒ ๋˜๊ณ , ๋ถ€๋ชจ์˜์—ญ(์ปจํ…Œ์ด๋„ˆ)์„ ๋„˜์–ด๊ฐ€๊ฒŒ ๋œ๋‹ค๋ฉด ์ผ์ •ํ•œ ๋น„์œจ๋กœย ์ค„์–ด๋“ค๊ฒŒย ๋œ๋‹ค. Flex๋ฅผ ์‚ฌ์šฉํ•˜๋‹ค ๋ณด๋ฉดย nowrap์ด๋ผ๋Š”ย ์†์„ฑ์„ ์ž์ฃผ ๋ณผ ์ผ์€ ์—†์ง€๋งŒ, ์ด ์†์„ฑ์„ ์‚ฌ์šฉํ•˜๋ฉด ์–ด๋–ป๊ฒŒ ๋ณ€ํ•˜๋Š”์ง€ ์•Œ์•„๋‘๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.
notion imagenotion image

5.2. flex-wrap : wrap

๋‹ค์Œ์œผ๋กœ flex-wrap ์†์„ฑ ์ค‘์— wrap์˜ ์†์„ฑ์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด์ž. Flex-wrap์˜ wrap์†์„ฑ์€ ๊ฐ ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)์˜ ์ด ๋„“์ด๊ฐ€ ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ ๋„“์ด ๋ณด๋‹ค ํด ๋•Œ, ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ) ์•ˆ์— ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)์ด ๋“ค์–ด๊ฐˆ ์ˆ˜ ์žˆ๋„๋ก ๋‹ค์Œ ์ค„์— ์ด์–ด์„œ ์ •๋ ฌํ•ด ์ฃผ๋Š” ์†์„ฑ์„ ๋งํ•œ๋‹ค.
์•ž์„œ ๋งํ•œ flex-wrap์—์„œ no-wrap์„ ์‚ฌ์šฉํ•˜๋ฉด ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)์˜ ์ด ๋„“์ด๊ฐ€ ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ ๋„“์ด๋ณด๋‹ค ํฐ ๊ฒฝ์šฐ ์ •๋ ฌ๋œ ์š”์†Œ๋“ค์€ ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ ๋„“์ด์— ๋งž์ถฐ ์ž๋™ ์ถ•์†Œ ๋˜๊ฒŒ ๋œ๋‹ค.
notion imagenotion image
๋ฐ˜๋ฉด, flex-wrap:wrap์˜ ๊ฒฝ์šฐ์—๋Š” ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)์˜ ๋„“์ด๋ฅผ ์œ ์ง€ํ•œ ์ฑ„๋กœ ๋‹ค์Œ ์ค„๋กœ ์ด์–ด์„œ ์ •๋ ฌ ๋˜๊ฒŒ ํ•œ๋‹ค. flex-wrap:wrap์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ, ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)์˜ ํฌ๊ธฐ์™€ ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์— ํฌ๊ธฐ์— ๋”ฐ๋ผ ๋‹ค์Œ ์ค„๋กœ ์ •๋ ฌ์ด ์ด์–ด์ง€๊ฒŒ ๋˜๋Š”๋ฐ ์ด๋Š” flex-direction์˜ ๋ฐฉํ–ฅ์„ ๋”ฐ๋ฅด๊ฒŒ ๋œ๋‹ค,
notion imagenotion image
๋งŒ์•ฝ flex-direction์˜ ๋ฐฉํ–ฅ์ด row(ํ–‰)๋ผ๋ฉด row(ํ–‰)์— ๋งž์ถฐ ์ฃผ์ถ•์ธ ์ˆ˜ํ‰์œผ๋กœย ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)๋“ค์ด ์ •๋ ฌ ๋˜๊ฒŒ ๋˜๊ณ , ๊ต์ฐจ์ถ•์ธ ์ˆ˜์ง์ถ•์œผ๋กœ ์•„์ดํ…œ์ด ์Œ“์ด๊ฒŒ ๋œ๋‹ค.
notion imagenotion image
flex-direction์˜ ๋ฐฉํ–ฅ์ด column(์—ด)์ด๋ผ๋ฉด column(์—ด)์— ๋งž์ถฐ ์ฃผ์ถ•์ธ ์ˆ˜์ง์œผ๋กœ ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)๋“ค์ด ์ •๋ ฌ ๋˜๊ฒŒ ๋˜๊ณ , ๊ต์ฐจ์ถ•์ธ ์ˆ˜ํ‰์ถ•์œผ๋กœ ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)์ค„์ด ์Œ“์ด๊ฒŒ ๋œ๋‹ค.
notion imagenotion image
์ด๋Ÿฌํ•œ ์ž๋™ ๋งž์ถค ๊ฐ™์€ flex-wrap:wrap์˜ ์„ฑ์งˆ์— ๋”ฐ๋ผ์„œ ํ™”๋ฉด์ด ์กฐ์ •๋˜๋Š” ๊ฒฝ์šฐ(ํŠนํžˆ ๋ฏธ๋””์–ด ์ฟผ๋ฆฌ๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒฝ์šฐ), ์•„์ดํ…œ์˜ ํฌ๊ธฐ๊ฐ€ ๋ณ€ํ•˜์ง€ ์•Š๊ณ  ์œ„์น˜๋งŒ ์กฐ์ •๋  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋งŽ์ด ์‚ฌ์šฉํ•˜๊ฒŒ ๋œ๋‹ค.

5.3. flex-wrap : wrap-reverse

flex-wrap : wrap-reverse; ๋Š” wrap-reverse: wrap; ๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)๋“ค์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ ์—ฌ๋Ÿฌ ์ค„์— ๊ฑธ์ณ ๋ฐฐ์น˜๋˜์ง€๋งŒ, ๋‹ค๋ฅธ ์ ์€ wrap-reverse์ด๊ธฐ ๋•Œ๋ฌธ์— ์ž์‹ ์š”์†Œ(์•„์ดํ…œ) ์š”์†Œ๋“ค์ด ์ •๋ ฌ๋˜๋Š” ๊ธฐ์ค€์ ์ด ๋ฐ˜๋Œ€ ๋ฐฉํ–ฅ์œผ๋กœ ๋ฐ”๋€Œ์–ด์„œ ๋ฐฐ์น˜๋œ๋‹ค.
์ ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์— display: flex๋ฅผ ์ฃผ๊ณ , flex-wrap: wrap-reverse ๊ฐ’์„ ์„ค์ •ํ•˜๋ฉด ๋œ๋‹ค.
.container { display: flex; flex-wrap: wrap-reverse; }
ย 
  • flex-wrap: wrap; ๊ณผ flex-wrap: wrap-reverse; ๋น„๊ต
notion imagenotion image
.container { display: flex; flex-wrap: wrap; }
display: flex; ์˜ ๊ฒฝ์šฐ flex-direction: row; ๊ฐ€ ๊ธฐ๋ณธ๊ฐ’์ด๋‹ค. ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— flex-wrap: wrap; ์ธ ๊ฒฝ์šฐ์—๋Š” ๋ถ€๋ชจ ์š”์†Œ์ธ ์ปจํ…Œ์ด๋„ˆ์˜ ์™ผ์ชฝ ์ถ•์˜ ์ƒ๋‹จ๋ถ€ํ„ฐ ์ž์‹ ์š”์†Œ์ธ ์•„์ดํ…œ๋“ค์ด ์ˆœ์ฐจ์ ์œผ๋กœ ๋ฐฐ์น˜๋œ๋‹ค. ์ฆ‰, ๋ฐฐ์น˜๊ฐ€ ์‹œ์ž‘๋˜๋Š” ๊ธฐ์ค€์ด ์ฃผ์ถ•(main-axis)์˜ main-start ์ง€์ ์ด ๋ถ€๋ชจ(์ปจํ…Œ์ด๋„ˆ)์˜ ์ƒ๋‹จ, ๊ต์ฐจ ์ถ•(cross-axis)์˜ cross-start ์ง€์ ์€ ๋ถ€๋ชจ(์ปจํ…Œ์ด๋„ˆ) ์™ผ์ชฝ์ด ๋œ๋‹ค.
ํ•˜์ง€๋งŒ, flex-wrap: wrap-reverse; ์˜ ๊ฒฝ์šฐ ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ ํ•˜๋‹จ์ธ ๋ฐ”๋‹ฅ ํ–‰์˜ ์™ผ์ชฝ์—์„œ๋ถ€ํ„ฐ 1, 2, 3โ€ฆ๋ฒˆ ์ˆœ์œผ๋กœ ์•„์ดํ…œ์ด ๋ฐฐ์น˜ ๋˜๊ณ  ๋‚˜๋จธ์ง€ ์š”์†Œ๋“ค์€ ๊ทธ ํ–‰ ์œ„์— ๋ฐฐ์น˜ ๋œ๋‹ค. ๋˜, ์ „์ฒด์ ์œผ๋กœ ๋ณด๋ฉด flex-wrap: wrap; ๊ณผ๋Š” ๋ฐ˜๋Œ€๋กœ ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)๋“ค์ด ์ปจํ…Œ์ด๋„ˆ์˜ ํ•˜๋‹จ์— ๋ถ™์–ด ๋ฐฐ์น˜ ๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.
notion imagenotion image
.container { display: flex; flex-wrap: wrap-reverse; }
reverse(์—ญ์ˆœ)์ด๊ธฐ ๋•Œ๋ฌธ์— ๋ฐฐ์น˜ ๋˜๋Š” ๊ธฐ์ค€์ ์ด ๋ฐ”๋€Œ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ์ฆ‰, flex-wrap: wrap-reverse; ๋ฅผ ์ฃผ๊ฒŒ ๋˜๋ฉด, ์ฃผ์ถ•(main-axis)์˜ main-start ์ง€์ ์ด ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ ํ•˜๋‹จ์ด ๋œ๋‹ค. ๊ทธ๋ž˜์„œ ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ ํ•˜๋‹จ ์™ผ์ชฝ์ด ๊ธฐ์ค€์ ์ด ๋˜์–ด ์ž์‹ ์š”์†Œ๋“ค(์•„์ดํ…œ๋“ค)์ด ์ˆœ์„œ๋Œ€๋กœ ๋ฐฐ์น˜ ๋˜๊ฒŒ ๋œ๋‹ค. ์ž์‹์š”์†Œ(์•„์ดํ…œ)๋Š” ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ width์— ๋งž์ถฐ ์ •๋ ฌ๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋ถ€๋ชจ์˜ witdh๋ฅผ ์ค„์ด๋ฉด, ๊ฐ ์ค„์— ๋“ค์–ด๊ฐ€๋Š” ์•„์ดํ…œ์˜ ๊ฐœ์ˆ˜ ์—ญ์‹œ ์•„๋ž˜ ์˜ˆ์‹œ์™€ ๊ฐ™์ด ๋ณ€๊ฒฝ๋˜๊ฒŒ ๋œ๋‹ค.
notion imagenotion image
๊ทธ๋ฆฌ๊ณ  flex-wrap: wrap; ๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ, flex-item ์š”์†Œ๋“ค์˜ ํฌ๊ธฐ๋ฅผ ์ปจํ…Œ์ด๋„ˆ ํฌ๊ธฐ์— ๋งž์ถฐ ์ค„์ด์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์—, flex-item(์ž์‹ ์š”์†Œ)์ด ๋ถ€๋ชจ(์ปจํ…Œ์ด๋„ˆ)์— ๋“ค์–ด๊ฐ€๊ธฐ์— ๋” ๋งŽ์€ ๋ถ€ํ”ผ๋ฅผ ์ฐจ์ง€ํ•˜๊ฒŒ ๋˜๋ฉด ์•„๋ž˜ ์ด๋ฏธ์ง€์ฒ˜๋Ÿผ ์•„์ดํ…œ๋“ค์ด ์ปจํ…Œ์ด๋„ˆ ๋ฐ–์œผ๋กœ ๋„˜์น˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.
notion imagenotion image
ย 
  • flex-direction: column; ๊ฐ’์„ ์ค€ ๊ฒฝ์šฐ flex-wrap: wrap-reverse; ๋Š” ์–ด๋–ป๊ฒŒ ๋ ๊นŒ?
display: flex; ๋ฅผ ์ค€ ๊ฒฝ์šฐ, flex-direction์˜ ๊ธฐ๋ณธ๊ฐ’์€ row์ง€๋งŒ, flex-direction: column; ์„ ์ค€๋‹ค๋ฉด ์œ„์—์„œ ํ™•์ธํ•œ ๊ฒƒ๋“ค๊ณผ๋Š” ๋‹ค๋ฅธ ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. flex์˜ ๋ฐฉํ–ฅ์ด row(ํ–‰)์ด ์•„๋‹Œ column(์—ด)์œผ๋กœ ๋ณ€๊ฒฝ๋˜๊ธฐ ๋•Œ๋ฌธ์— ์ฃผ์ถ•(main-axis)์ด ์ˆ˜ํ‰(๊ฐ€๋กœ)์ด ์•„๋‹Œ ์ˆ˜์ง(์„ธ๋กœ) ๋ฐฉํ–ฅ์ด ๋œ๋‹ค.
๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์—, flex-direction: column; ์ธ ์ƒํƒœ์—์„œ flex-wrap: wrap-reverse; ๋ฅผ ์ฃผ๊ฒŒ ๋˜๋ฉด, ์ฃผ์ถ•(main-axis)์˜ main-start ์ง€์ ์ด ๋ถ€๋ชจ ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ)์˜ ์˜ค๋ฅธ์ชฝ ๋ ์ง€์ ์ด ๋˜๊ณ , ์˜ค๋ฅธ์ชฝ ๋์˜ ์—ด(column)๋ถ€ํ„ฐ ์•„์ดํ…œ์ด ์ฐจ๋ก€๋Œ€๋กœ ๋ฐฐ์น˜๋œ๋‹ค.
notion imagenotion image

6. Flex-basis

6.1. flex-basis๋ž€?

flex-basis๋Š” ์ž์‹ ์š”์†Œ(์•„์ดํ…œ)์— ์‚ฌ์šฉํ•˜๋Š” ์†์„ฑ์ด๋‹ค.
.item { flex-basis: auto; /* ๊ธฐ๋ณธ๊ฐ’ */ }
๋ถ€๋ชจ ์š”์†Œ์ธ ์ปจํ…Œ์ด๋„ˆ์˜ ์ฃผ ์ถ•(main axis)์ด ๋˜๋Š” ๋ฐฉํ–ฅ์œผ๋กœ flex ์•„์ดํ…œ์˜ ์ดˆ๊ธฐ ํฌ๊ธฐ(default size)๋ฅผ ์ •ํ•ด์ค„ ์ˆ˜ ์žˆ๋‹ค. ์ปจํ…Œ์ด๋„ˆ์˜ ์•„์ดํ…œ ๋ฐฐ์น˜ ๋ฐฉํ–ฅ(flex-direction)์ด ๊ฐ€๋กœ(row) ์ถ•์ผ ๊ฒฝ์šฐ ๋„“์ด๋ฅผ, ์„ธ๋กœ(column) ์ถ•์ผ ๊ฒฝ์šฐ ๋†’์ด๋ฅผ ์ง€์ •ํ•œ๋‹ค.

6.2. flex-basis์— ๋“ค์–ด๊ฐ€๋Š” ๊ฐ’

flex-basis์˜ ๊ฐ’์œผ๋กœ๋Š” ์šฐ๋ฆฌ๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ๊ฐ์ข… ๋‹จ์œ„๊ฐ€ ๋“ค์–ด๊ฐˆ ์ˆ˜ ์žˆ๋‹ค. ๊ธธ์ด๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋‹จ์œ„๋“ค์ธย em,ย rem,ย px์ด๋‚˜ ํผ์„ผํ‹ฐ์ง€(%) ๊ฐ’์ด ๋  ์ˆ˜๋„ ์žˆ๊ณ , content, min-content, max-content, fit-content, fill, auto ๋“ฑ์˜ ํ‚ค์›Œ๋“œ๊ฐ€ ๋  ์ˆ˜๋„ ์žˆ๋‹ค. ์ƒ์ˆ˜๋Š” 0 ์™ธ์— ๋‹ค๋ฅธ ๊ฐ’์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋‹ค.

6.3. flex-basis์˜ ์œ ์—ฐ์„ฑ

flex-basis ์†์„ฑ์€ ์œ ์—ฐํ•œ(flexible) ํฌ๊ธฐ๋ฅผ ๊ฐ€์ง„๋‹ค. ์ฆ‰, ๊ณ ์ •์ ์ธ width, height ๊ฐ’์„ ์ง€์ •ํ•ด ์ค„ ๋•Œ์™€ ๋‹ฌ๋ฆฌ ์ถ•์˜ ๋ฐฉํ–ฅ์— ๋”ฐ๋ผ, ๋˜ ๋‚ด๋ถ€ ์ฝ˜ํ…์ธ ์— ๋”ฐ๋ผ ํฌ๊ธฐ๊ฐ€ ๊ฐ€๋ณ€์ , ์œ ๋™์ ์œผ๋กœ ๋ณ€ํ•  ์ˆ˜ ์žˆ๋‹ค.
์•„์ดํ…œ์ด height: 40px;์ผ ๋•Œ(๋‚ด๋ถ€ ์ฝ˜ํ…์ธ ์˜ ํฌ๊ธฐ๋Š” ๊ณ ๋ คํ•˜์ง€ ์•Š๊ณ  40px์— ๋งž์ถค)์•„์ดํ…œ์ด height: 40px;์ผ ๋•Œ(๋‚ด๋ถ€ ์ฝ˜ํ…์ธ ์˜ ํฌ๊ธฐ๋Š” ๊ณ ๋ คํ•˜์ง€ ์•Š๊ณ  40px์— ๋งž์ถค)
์•„์ดํ…œ์ด height: 40px;์ผ ๋•Œ(๋‚ด๋ถ€ ์ฝ˜ํ…์ธ ์˜ ํฌ๊ธฐ๋Š” ๊ณ ๋ คํ•˜์ง€ ์•Š๊ณ  40px์— ๋งž์ถค)
์•„์ดํ…œ์ด flex-basis: 40px;์ผ ๋•Œ(์ฝ˜ํ…์ธ ์˜ ํฌ๊ธฐ์— ๋งž์ถค)์•„์ดํ…œ์ด flex-basis: 40px;์ผ ๋•Œ(์ฝ˜ํ…์ธ ์˜ ํฌ๊ธฐ์— ๋งž์ถค)
์•„์ดํ…œ์ด flex-basis: 40px;์ผ ๋•Œ(์ฝ˜ํ…์ธ ์˜ ํฌ๊ธฐ์— ๋งž์ถค)

6.4. flex-basis์™€ width/height์˜ ๊ด€๊ณ„

๊ธฐ๋ณธ๊ฐ’ auto๋Š” ํ•ด๋‹น ์•„์ดํ…œ์˜ width(๋˜๋Š” height) ๊ฐ’์„ ์‚ฌ์šฉํ•˜๊ฒŒ ๋œ๋‹ค. ๋งŒ์•ฝ width๊ฐ’์ด ์—†๋‹ค๋ฉด ์ฝ˜ํ…์ธ ์˜ ํฌ๊ธฐ๊ฐ€ ๊ธฐ๋ณธ์œผ๋กœ ์žกํžˆ๊ฒŒ ๋œ๋‹ค.
notion imagenotion image
์œ„ ๊ทธ๋ฆผ์—์„œ๋Š” basis์˜ ๊ฐ’์„ 100px๋กœ ์„ค์ •ํ–ˆ๋‹ค. ์ฝ˜ํ…์ธ ์˜ ํฌ๊ธฐ๊ฐ€ ์ ์œผ๋ฉด 100px๋กœ ์•„์ดํ…œ๋“ค์˜ width๊ฐ€ ๊ฒฐ์ •๋˜์ง€๋งŒ, ์ฝ˜ํ…์ธ ๊ฐ€ ๋งŽ์•„์ง€๊ฒŒ ๋˜๋ฉด basis๋ณด๋‹ค ๋„“์–ด์ง€๊ฒŒ ๋œ๋‹ค.
notion imagenotion image
๋ฐ˜๋ฉด, width๊ฐ’์„ 100px๋กœ ์„ค์ •ํ•˜๊ฒŒ ๋˜๋ฉด basis์™€ ๋‹ฌ๋ฆฌ ์ปจํ…์ธ ์˜ ํฌ๊ธฐ๊ฐ€ ๋งŽ์•„์ง€๋ฉด ์•„์ดํ…œ์˜ width๋Š” 100px๋กœ ๊ณ ์ •๋˜๊ณ , ์ปจํ…์ธ ๊ฐ€ ๋ฐ–์œผ๋กœ ๋‚˜๊ฐ€๊ฒŒ ๋œ๋‹ค. ์ด๋ฅผ ๋ฐฉ์ง€ํ•˜๋ ค๋ฉดย word-wrap: break-word;ย ๊ฐ’์„ ์ฃผ๋ฉด ํ•ด๊ฒฐ๋œ๋‹ค.
notion imagenotion image
๊ธฐ๋ณธ์ ์œผ๋กœ flex-basis ์†์„ฑ์ด width(๋˜๋Š” height) ๊ฐ’๋ณด๋‹ค ์šฐ์„ ํ•˜๊ฒŒ ๋œ๋‹ค. ์ฆ‰, width๋ฅผ 100px์„ ์ฃผ๊ณ  basis๋ฅผ 300px๋กœ ์ฃผ๊ฒŒ ๋˜๋ฉด basis๊ฐ’์ด ์šฐ์„ ์‹œ๋˜์–ด ์•„์ดํ…œ๋“ค์˜ ๊ธฐ๋ณธ๋„ˆ๋น„๊ฐ€ 300px๋กœ ์žกํžˆ๊ฒŒ ๋œ๋‹ค. ์ฃผ์˜ํ•  ์ ์€ ์„œ๋กœ ๋‹ค๋ฅธ ๊ฐ’์ผ ๊ฒฝ์šฐ ๊ธฐ๋ณธ์ ์œผ๋กœ flex-basis๊ฐ€ ์šฐ์„ ํ•˜์ง€๋งŒ, ๋˜‘๊ฐ™์€ ๊ฐ’์„ flex-basis์™€ width(๋˜๋Š” height)์— ์ฃผ๊ณ  ๋™์‹œ์— ์ ์šฉํ•  ๊ฒฝ์šฐ์—” width(๋˜๋Š” height)์˜ ์ ์šฉ์ด ์šฐ์„ ์‹œ๋œ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. ๋˜ํ•œ, ์–ธ์–ด๊ฐ€ ํ•œ๊ธ€์ธ์ง€ ์˜์–ด์ธ์ง€์™€ word-break ๋“ฑ ๋‹ค๋ฅธ ์†์„ฑ๊ฐ’์— ๋”ฐ๋ผ flex-basis๋Š” ์˜ˆ์ƒ๊ณผ ๋‹ค๋ฅด๊ฒŒ ๋™์ž‘ํ•  ์ˆ˜๋„ ์žˆ๋‹ค.

6.5. flex-basis : auto; ์™€ flex-basis : 0;

flex-basis: auto;๊ฐ€ ๊ธฐ๋ณธ๊ฐ’์ด๋‹ค. ์ด๋•Œ๋Š” ์ง€์ •ํ•ด ์ค€ width(๋˜๋Š” height) ๊ฐ’์„ ์‚ฌ์šฉํ•˜๊ฑฐ๋‚˜, ๋‹ค๋ฅธ ๋ฐ•์Šค๊ฐ€ ๋Š˜์–ด๋‚  ๋•Œ ๊ฐ™์ด ๋Š˜์–ด๋‚œ๋‹ค(stretch). ๋˜ํ•œ, ์ถ”๊ฐ€ ๊ณต๊ฐ„์ด flex-grow ๊ฐ’์— ๋”ฐ๋ผ ๋ถ„๋ฐฐ๋œ๋‹ค. auto ์ผ ๋•Œ์™€๋Š” ๋‹ฌ๋ฆฌ flex-basis: 0;์œผ๋กœ ์„ค์ •ํ•˜๋ฉด ๋‚ด์šฉ ์ฃผ์œ„์˜ ์ถ”๊ฐ€ ๊ณต๊ฐ„์ด ๊ณ ๋ ค๋˜์ง€ ์•Š๋Š”๋‹ค.
flex-basis ๊ฐ’์ด 0์ผ ๋•Œ์™€ auto์ผ ๋•Œ์˜ ์ฐจ์ดflex-basis ๊ฐ’์ด 0์ผ ๋•Œ์™€ auto์ผ ๋•Œ์˜ ์ฐจ์ด
flex-basis ๊ฐ’์ด 0์ผ ๋•Œ์™€ auto์ผ ๋•Œ์˜ ์ฐจ์ด

6.6. flex-basis : content;

flex-basis: content;๋Š” ์ฝ˜ํ…์ธ  ํฌ๊ธฐ์— ๋งž๊ฒŒ ์ž๋™์œผ๋กœ ํฌ๊ธฐ๊ฐ€ ์กฐ์ ˆ๋œ๋‹ค. ๊ณ ์œ  ํฌ๊ธฐ ์กฐ์ • ํ‚ค์›Œ๋“œ๋กœ๋Š” fill, min-content, max-content, fit-content ๊ฐ€ ์žˆ๋‹ค.
notion imagenotion image
์ด ํ‚ค์›Œ๋“œ๋Š” ์ž˜ ์ง€์›๋˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ํ…Œ์ŠคํŠธํ•˜๊ธฐ ์–ด๋ ต๋‹ค (2022๋…„ ๊ธฐ์ค€). ๋”ฐ๋ผ์„œ min-content, max-content ๋ฐ fit-content์˜ ๊ธฐ๋Šฅ์„ ์™„์ „ํžˆ ํŒŒ์•…ํ•˜์—ฌ ์›ํ•˜๋Š” ์˜๋„๋Œ€๋กœ ์‚ฌ์šฉํ•˜๊ธฐ์—” ์•„์ง ๋ฌด๋ฆฌ๊ฐ€ ์žˆ๋‹ค.

6.7. flex-basis๋ณด๋‹ค๋Š” flex ์ถ•์•ฝ ์†์„ฑ์„! (W3C)

CSS ํ‘œ์ค€์„ ๊ด€๋ฆฌํ•˜๋Š” W3C์— ๋”ฐ๋ฅด๋ฉด, flex-basis ์†์„ฑ์„ ์ง์ ‘ ์‚ฌ์šฉํ•˜๊ธฐ๋ณด๋‹ค๋Š” flex ์ถ•์•ฝ ์†์„ฑ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•˜๊ณ  ์žˆ๋‹ค.

6.8. flex-basis ํ˜ธํ™˜์„ฑ

7. Flex-grow

7.1. flex-grow๋ž€?

flex-grow๋Š” ์ž์‹ ์š”์†Œ์ธ flex-item์ด ์ฐจ์ง€ํ•˜๋Š” ๋น„์œจ์„ ์กฐ์ ˆํ•˜๋Š” ์†์„ฑ์ด๋‹ค. ์ปจํ…Œ์ด๋„ˆ ํฌ๊ธฐ์— ๋งž์ถฐ ๋Š˜์–ด๋‚˜๋Š” ๋น„์œจ์ด ์—ฌ๋ฐฑ์„ ์ฐจ์ง€ํ•˜๋ฉด์„œ ์ด ์†์„ฑ์„ ๊ฐ€์ง„ ๋‹ค๋ฅธ ์š”์†Œ๋“ค๊ณผ ๋™์ผํ•˜๊ฒŒ ๋ถ„๋ฐฐํ•œ๋‹ค. ์‰ฝ๊ฒŒ ๋งํ•ด์„œ flex-grow์˜ ๊ฐ’์€ ์•„์ดํ…œ๋“ค์˜ flex-basis๋ฅผ ์ œ์™ธํ•œ ์—ฌ๋ฐฑ ๋ถ€๋ถ„์„ flex-grow์˜ ๋น„์œจ๋กœ ๊ฐ๊ฐ ๋‚˜๋ˆ„์–ด ๊ฐ€์ง„๋‹ค.

7.2. flex-grow ๊ธฐ๋Šฅ : ํ™•์žฅ ๋˜๋Š” ๊ณ ์ •

.item { flex-shrink: 0; /* ๊ธฐ๋ณธ๊ฐ’ */ }
/* <number> values */ flex-grow: 1 | 0.5; /* Global values */ flex-grow: inherit | initial | unset;
์ถœ์ฒ˜: MDN
flex-grow ์†์„ฑ์€ ๊ธฐ๋ณธ๊ฐ’์ด 0 ์ด๋‹ค. flex-grow:0 ์ผ๋•Œ๋Š” flex item์„ ํ™•์žฅํ•˜์ง€ ์•Š๊ณ  ์›๋ž˜์˜ ํฌ๊ธฐ๋ฅผ ์œ ์ง€ํ•œ๋‹ค.
์˜ˆ์‹œ1. flex-grow:0 (๊ธฐ๋ณธ ๊ฐ’)์˜ˆ์‹œ1. flex-grow:0 (๊ธฐ๋ณธ ๊ฐ’)
์˜ˆ์‹œ1. flex-grow:0 (๊ธฐ๋ณธ ๊ฐ’)
flex-grow:1 ์ผ ๋•Œ๋Š” flex item ์ด ์œ ์—ฐํ•œ ๋ฐ•์Šค์˜ ํ˜•ํƒœ๋กœ ๋ฐ”๋€Œ๋ฉฐ ๋นˆ ๊ณต๊ฐ„์„ ์ฑ„์šด๋‹ค.
์˜ˆ์‹œ2. flex-grow:1์˜ˆ์‹œ2. flex-grow:1
์˜ˆ์‹œ2. flex-grow:1
๊ฐ๊ฐ์˜ ์•„์ดํ…œ๋ณ„๋กœ flex-grow ๊ฐ’์„ ์ค„ ์ˆ˜๋„ ์žˆ๋‹ค. flex-grow ์— ์ •ํ•ด์ค€ ๋น„์œจ๋งŒํผ ์—ฌ๋ถ„์˜ ์ปจํ…Œ์ด๋„ˆ ๋„ˆ๋น„๋ฅผ ๋ถ„๋ฐฐํ•˜์—ฌ ๊ฐ–๋Š”๋‹ค.
์˜ˆ์‹œ3. ๊ฐ๊ฐ์˜ ์•„์ดํ…œ๋ณ„๋กœ ๋‹ค๋ฅธ flex-grow์˜ˆ์‹œ3. ๊ฐ๊ฐ์˜ ์•„์ดํ…œ๋ณ„๋กœ ๋‹ค๋ฅธ flex-grow
์˜ˆ์‹œ3. ๊ฐ๊ฐ์˜ ์•„์ดํ…œ๋ณ„๋กœ ๋‹ค๋ฅธ flex-grow

7.3. flex-grow ์‚ฌ์šฉ ์‹œ ์ฃผ์˜ํ•  ์ 

flex-grow ์†์„ฑ์€ 0 ๋˜๋Š” ์–‘์˜ ์ •์ˆ˜์˜ ๊ฐ’์œผ๋กœ ์„ค์ •ํ•ด์•ผ ํ•œ๋‹ค. ์Œ์ˆ˜์˜ ๊ฐ’์œผ๋กœ ์„ค์ •ํ–ˆ์„ ๊ฒฝ์šฐ, ๊ธฐ๋ณธ๊ฐ’์ธ flex-grow:0์ผ ๋•Œ์™€ ๊ฐ™๋‹ค. ๋˜ํ•œ flex-grow์˜ ์ฆ๊ฐ€๋„ˆ๋น„ ๋น„์œจ์€ width๋กœ ์ธํ•ด ์˜ํ–ฅ์„ ๋ฐ›๋Š”๋‹ค. ๋•Œ๋ฌธ์— flex-basis๋กœ flex์˜ ๊ฐ€๋ณ€ ๋ฒ”์œ„์— ์ž…๋ ฅํ•˜์—ฌ ๊ธฐ๋ณธ๊ฐ’์„ ์ •ํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.
์˜ˆ์‹œ4. flex-grow:-1์˜ˆ์‹œ4. flex-grow:-1
์˜ˆ์‹œ4. flex-grow:-1

7.4. flex ์ถ•์•ฝ ์†์„ฑ

flex: flex-grow | flex-shrink | flex-basis;
์ผ๋ฐ˜์ ์œผ๋กœ๋Š” ๋ชจ๋“  ๊ฐ’์ด ์„ค์ •๋˜์—ˆ์Œ์„ ๋ณด์žฅํ•˜๊ธฐ ์œ„ํ•˜์—ฌย flex ์†์„ฑ์„ ์ด์šฉํ•ดย ์ถ•์•ฝํ˜•์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. ์ถ•์•ฝ ์†์„ฑ์˜ ์ˆœ์„œ๋Š” flex-grow, flex-shrink, flex-basis ์ˆœ์œผ๋กœ ์ ์šฉ๋˜๋ฉฐ ๋„์–ด์“ฐ๊ธฐ๋กœ ๊ตฌ๋ถ„ํ•œ๋‹ค.
Flex ์ถ•์•ฝ ์†์„ฑ์˜ ๊ธฐ๋ณธ๊ฐ’์€ flex: 0 1 auto; ์ด๋‹ค. flex-grow๋ฅผ ์ œ์™ธํ•œ ๊ฐœ๋ณ„ ์†์„ฑ์€ ์ƒ๋žตํ•  ์ˆ˜ ์žˆ๋‹ค. flex : 1; ํ•  ๊ฒฝ์šฐ grow๋Š” 1๋กœ ๋ณ€ํ•˜๊ณ  shrink์˜ ๊ฐ’์€ 0์œผ๋กœ basis์˜ ๊ฐ’์„ ๋ช…์‹œ์ ์œผ๋กœ ์ž‘์„ฑํ•˜์ง€ ์•Š์œผ๋ฉด 0์œผ๋กœ ์ž…๋ ฅ์ด ๋œ๋‹ค.

7.5. flex-shrink๋ณด๋‹ค๋Š” flex ์ถ•์•ฝ ์†์„ฑ์„! (W3C)

CSS ํ‘œ์ค€์„ ๊ด€๋ฆฌํ•˜๋Š” W3C์— ๋”ฐ๋ฅด๋ฉด, flex-shrink์†์„ฑ์„ ์ง์ ‘ ์‚ฌ์šฉํ•˜๊ธฐ๋ณด๋‹ค๋Š” flex ์ถ•์•ฝ ์†์„ฑ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•˜๊ณ  ์žˆ๋‹ค.
https://www.w3.org/TR/css-flexbox-1/#propdef-flex-growhttps://www.w3.org/TR/css-flexbox-1/#propdef-flex-grow

7.6. flex-grow ํ˜ธํ™˜์„ฑ

์ง€์›๋ฒ„์ „
์ถœ์ฒ˜: mdn์ถœ์ฒ˜: mdn
์ถœ์ฒ˜: mdn

8. Flex-shrink

8.1. Flex-shrink ๋ž€?

flex-shrink๋Š” ์ž์‹ ์š”์†Œ์— ์‚ฌ์šฉํ•˜๋Š” ์†์„ฑ์ด๋‹ค. flex ์ปจํ…Œ์ด๋„ˆ ์•ˆ์—์„œ ์ž์‹ ์š”์†Œ์ธ flex ์•„์ดํ…œ ์š”์†Œ๋ฅผ ์ž๋™์œผ๋กœ ์ค„์—ฌ์„œ ์ ์ ˆํ•œ ํฌ๊ธฐ๋กœ ๋ฐฐ์น˜ํ•ด ์œ ์—ฐํ•œ ๋ ˆ์ด์•„์›ƒ์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค๋Š” ์žฅ์ ์ด ์žˆ๋‹ค. flex-basis ์†์„ฑ์œผ๋กœ ์ง€์ •๋œ ์•„์ดํ…œ์˜ ๊ธฐ๋ณธ ํฌ๊ธฐ๋ฅผ ์„ค์ •ํ•œ ์ˆซ์ž ๊ฐ’์— ๋น„๋ก€ํ•ด ์ˆ˜์ถ•์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค. flex-grow์™€๋Š” ๋ฐ˜๋Œ€๋˜๋Š” ๊ฐœ๋…์ด๋‹ค.

8.2. Flex-shrink ๊ธฐ๋Šฅ: ์ถ•์†Œ ๋˜๋Š” ๊ณ ์ •

.item { flex-shrink: 1; /* ๊ธฐ๋ณธ๊ฐ’ */ }
flex-shrink์†์„ฑ์˜ ๊ธฐ๋ณธ๊ฐ’์€ 1์ด๋‹ค. ์ฆ‰, ์ •์˜ํ•˜์ง€ ์•Š์•„๋„ ์ž๋™์œผ๋กœ ์ถ•์†Œ๋œ๋‹ค. ์ˆซ์ž๊ฐ€ ํด์ˆ˜๋ก ์ƒ๋Œ€์ ์œผ๋กœ ๋” ์ž‘์€ ํฌ๊ธฐ๋ฅผ ๊ฐ–๊ฒŒ ๋œ๋‹ค. ๊ฐ’์„ 0์œผ๋กœ ์„ ์–ธํ•  ๊ฒฝ์šฐ ๋„ˆ๋น„ ํ˜น์€ ๋†’์ด๋ฅผ ๊ณ ์ •ํ•ด์„œ ํ•ญ์ƒ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ๋‹ค.
ย 
์˜ˆ์‹œ1. flex-shrink:1 (๊ธฐ๋ณธ๊ฐ’)์˜ˆ์‹œ1. flex-shrink:1 (๊ธฐ๋ณธ๊ฐ’)
์˜ˆ์‹œ1. flex-shrink:1 (๊ธฐ๋ณธ๊ฐ’)
์˜ˆ์‹œ2. flex-shrink:0์˜ˆ์‹œ2. flex-shrink:0
์˜ˆ์‹œ2. flex-shrink:0
์˜ˆ์‹œ3. ์•„์ดํ…œ ๋ณ„๋กœ ๋‹ค๋ฅธ ๊ฒฝ์šฐ์˜ˆ์‹œ3. ์•„์ดํ…œ ๋ณ„๋กœ ๋‹ค๋ฅธ ๊ฒฝ์šฐ
์˜ˆ์‹œ3. ์•„์ดํ…œ ๋ณ„๋กœ ๋‹ค๋ฅธ ๊ฒฝ์šฐ

8.3. Flex-shrink ์‚ฌ์šฉ ์‹œ ์ฃผ์˜ํ•  ์ 

flex-shrink ์†์„ฑ์€ ๋ถ€๋ชจ ์ปจํ…Œ์ด๋„ˆ์— flex-wrap: wrap; ์†์„ฑ์„ ๋ถ€์—ฌํ•œ ๊ฒฝ์šฐ ์ ์šฉ๋˜์ง€ ์•Š๋Š”๋‹ค. ๋”ฐ๋ผ์„œ ์ ์šฉ์„ ์œ„ํ•ด์„œ๋Š” wrap์„ ์ •์˜ํ•˜์ง€ ์•Š๊ฑฐ๋‚˜, nowrap์†์„ฑ์ด ๋ถ€์—ฌ๋˜์–ด์•ผ ํ•œ๋‹ค.
๐Ÿ’ก
flex-basis: 250px ํ†ต์ผ, 3๋ฒˆ์งธ ์•„์ดํ…œ๋งŒ flex-shrink: 2 ์ผ ๋•Œ (์˜ˆ์‹œ3, 4)
์˜ˆ์‹œ3. ๋ถ€๋ชจ ์ปจํ…Œ์ด๋„ˆ flex-wrap: nowrap;์˜ˆ์‹œ3. ๋ถ€๋ชจ ์ปจํ…Œ์ด๋„ˆ flex-wrap: nowrap;
์˜ˆ์‹œ3. ๋ถ€๋ชจ ์ปจํ…Œ์ด๋„ˆ flex-wrap: nowrap;
ย 
์˜ˆ์‹œ4. ๋ถ€๋ชจ ์ปจํ…Œ์ด๋„ˆ flex-wrap: wrap; (โ‡’ flex-shrink ์ ์šฉ๋˜์ง€ ์•Š์Œ)์˜ˆ์‹œ4. ๋ถ€๋ชจ ์ปจํ…Œ์ด๋„ˆ flex-wrap: wrap; (โ‡’ flex-shrink ์ ์šฉ๋˜์ง€ ์•Š์Œ)
์˜ˆ์‹œ4. ๋ถ€๋ชจ ์ปจํ…Œ์ด๋„ˆ flex-wrap: wrap; (โ‡’ flex-shrink ์ ์šฉ๋˜์ง€ ์•Š์Œ)

8.4. Flex ์ถ•์•ฝ ์†์„ฑ

flex: <flex-grow> <flex-shrink> <flex-basis>
flex-grow , flex-shrink , flex-basis ์†์„ฑ์˜ ๊ฐ’์„ ๋‹จ์ถ•ํ•ด์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์ด flex ์ถ•์•ฝ ์†์„ฑ์ด๋‹ค. ์ˆœ์„œ๋Š” grow, shrink, basis ์ˆœ์œผ๋กœ ์ ์šฉ๋œ๋‹ค.
  • flex-grow ๋Š” flex ์•„์ดํ…œ์ด ํŒฝ์ฐฝํ•˜๋Š” ๋น„์œจ์„ ์„ค์ •ํ•œ๋‹ค. ๊ธฐ๋ณธ๊ฐ’์€ 0์ด๋‹ค.
  • flex-shrink ๋Š” flex ์•„์ดํ…œ์ด ์ˆ˜์ถ•ํ•˜๋Š” ๋น„์œจ์„ ์„ค์ •ํ•œ๋‹ค. ๊ธฐ๋ณธ๊ฐ’์€ 1์ด๋‹ค.
  • flex-basis ๋Š” flex ์•„์ดํ…œ์ด ํŒฝ์ฐฝํ•˜๊ณ  ์ˆ˜์ถ•ํ•˜๋Š” ๊ธฐ์ค€ ํฌ๊ธฐ๋ฅผ ์„ค์ •ํ•œ๋‹ค. ๊ธฐ๋ณธ๊ฐ’์€ auto์ด๋‹ค.

8.5. Flex-shrink๋ณด๋‹ค๋Š” Flex ์ถ•์•ฝ ์†์„ฑ์„! (W3C)

CSS ํ‘œ์ค€์„ ๊ด€๋ฆฌํ•˜๋Š” W3C์— ๋”ฐ๋ฅด๋ฉด, flex-shrink์†์„ฑ์„ ์ง์ ‘ ์‚ฌ์šฉํ•˜๊ธฐ๋ณด๋‹ค๋Š” flex ์ถ•์•ฝ ์†์„ฑ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•˜๊ณ  ์žˆ๋‹ค.
https://www.w3.org/TR/css-flexbox-1/#propdef-flex-shrinkhttps://www.w3.org/TR/css-flexbox-1/#propdef-flex-shrink

8.6. Flex-shrink ํ˜ธํ™˜์„ฑ (caniuse)

9. ๊ทธ ๋ฐ–์˜ Flex-item์— ์‚ฌ์šฉํ•˜๋Š” ์†์„ฑ๋“ค

๊ธฐํƒ€ flex-item์— ์‚ฌ์šฉํ•˜๋Š” ์†์„ฑ์—๋Š” align-self, order, ๊ทธ๋ฆฌ๊ณ  z-index๊ฐ€ ์žˆ๋‹ค.

9.1. align-self

align-self๋ž€ ๊ต์ฐจ ์ถ•(cross-axis)์„ ๊ธฐ์ค€์œผ๋กœ ๊ฐœ๋ณ„์•„์ดํ…œ ์š”์†Œ์˜ ์ •๋ ฌ ๋ฐฉ๋ฒ•์„ ๊ฒฐ์ •ํ•˜๋Š” ์†์„ฑ์ด๋‹ค. Flex ์ปจํ…Œ์ด๋„ˆ์— ์ ์šฉํ•˜์—ฌ ๋‚ด๋ถ€์— ์žˆ๋Š” ์ „์ฒด ์•„์ดํ…œ์„ ์ •๋ ฌํ•˜๋Š” align-items์™€ ๋‹ฌ๋ฆฌ, align-self๋Š” ์ธ์ ‘ํ•œ Flex ์•„์ดํ…œ์— ์˜ํ–ฅ์„ ์ฃผ์ง€ ์•Š๊ณ , ๊ฐ๊ฐ์˜ Flex ์•„์ดํ…œ ์œ„์น˜๋ฅผ ์ž์œ ๋กญ๊ฒŒ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ „์ฒด ์„ค์ •์ธ align-items๋ณด๋‹ค, ๊ฐœ๋ณ„ ์•„์ดํ…œ์— ์ ์šฉ๋˜๋Š” align-self ์†์„ฑ์ด ์šฐ์„ ํ•œ๋‹ค๋Š” ํŠน์ง•์ด ์žˆ๋‹ค.
align-self์˜ ์†์„ฑ๊ฐ’
align-self์˜ ์†์„ฑ๊ฐ’์€, auto ๊ฐ’์„ ์ œ์™ธํ•˜๋ฉด align-items์˜ ์†์„ฑ๊ฐ’๊ณผ ๊ฐ™๋‹ค.
  • auto : ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ, ํ”Œ๋ ‰์Šค๋ฐ•์Šค ์ปจํ…Œ์ด๋„ˆ์˜ align-items ์†์„ฑ์„ ์ƒ์†๋ฐ›๋Š”๋‹ค. align-items์˜ ๊ธฐ๋ณธ ์†์„ฑ์€ stretch์ด๊ธฐ ๋•Œ๋ฌธ์—, align-items๊ฐ€ ์ง€์ •๋˜์–ด์žˆ์ง€ ์•Š๋Š” ๊ฒฝ์šฐ stretch ์†์„ฑ์„ ์ƒ์†๋ฐ›๋Š”๋‹ค.
  • stretch : ๊ต์ฐจ ์ถ•์„ ๊ธฐ์ค€์œผ๋กœ, ์ปจํ…Œ์ด๋„ˆ์˜ ๋†’์ด๋ฅผ ์ฑ„์šฐ๊ธฐ ์œ„ํ•ด ํ”Œ๋ ‰์Šค ์•„์ดํ…œ์ด ๋Š˜์–ด๋‚œ๋‹ค.
  • flex-start : ๊ต์ฐจ ์ถ•์„ ๊ธฐ์ค€์œผ๋กœ, ํ”Œ๋ ‰์Šค ์•„์ดํ…œ์ด ์ปจํ…Œ์ด๋„ˆ์˜ ์‹œ์ž‘์ ์— ์ •๋ ฌ๋œ๋‹ค.
  • flex-end : ๊ต์ฐจ ์ถ•์„ ๊ธฐ์ค€์œผ๋กœ, ํ”Œ๋ ‰์Šค ์•„์ดํ…œ์ด ์ปจํ…Œ์ด๋„ˆ์˜ ๋์ ์— ์ •๋ ฌ๋œ๋‹ค.
  • center : ๊ต์ฐจ ์ถ•์„ ๊ธฐ์ค€์œผ๋กœ, ํ”Œ๋ ‰์Šค ์•„์ดํ…œ์ด ์ปจํ…Œ์ด๋„ˆ์˜ ์ค‘์•™์— ์ •๋ ฌ๋œ๋‹ค.
  • baseline : ๊ต์ฐจ ์ถ•์„ ๊ธฐ์ค€์œผ๋กœ, ํ”Œ๋ ‰์Šค ์•„์ดํ…œ์ด ์ปจํ…Œ์ด๋„ˆ์˜ ๋ฌธ์ž ๊ธฐ์ค€์„ ์— ์ •๋ ฌ๋œ๋‹ค.
์•„๋ž˜๋Š” ์•„์ดํ…œ์— auto, stretch, flex-start, flex-end, center, baseline ์†์„ฑ๊ฐ’์„ ๋ถ€์—ฌํ•œ ๋ชจ์Šต์ด๋‹ค. ์ปจํ…Œ์ด๋„ˆ๊ฐ€ flex-direction:row; ์ธ ๊ฒฝ์šฐ ๊ต์ฐจ ์ถ•์ธ ์„ธ๋กœ์ถ•์„ ๊ธฐ์ค€์œผ๋กœ, ์•„์ดํ…œ๋“ค์ด ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์ฑ„์šด๋‹ค.
notion imagenotion image
.container{ display: flex; flex-direction: row; } .item:nth-child(1){align-self: auto;} .item:nth-child(2){align-self: stretch;} .item:nth-child(3){align-self: flex-start;} .item:nth-child(4){align-self: flex-end;} .item:nth-child(5){align-self: center;} .item:nth-child(6){align-self: baseline;}
flex-direction:column; ์ผ ๋•Œ๋Š” ๊ต์ฐจ ์ถ•์ธ ๊ฐ€๋กœ์ถ•์„ ๊ธฐ์ค€์œผ๋กœ, ์•„์ดํ…œ๋“ค์ด ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์ฑ„์šด๋‹ค.
notion imagenotion image
.container{ display: flex; flex-direction: column; }
ย 
align-self์˜ ํ™œ์šฉ ์˜ˆ์‹œ
์•„๋ž˜๋Š” Flex ์ปจํ…Œ์ด๋„ˆ์˜ ์•„์ดํ…œ๋“ค์„ align-self ์†์„ฑ์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ„๋‹จํ•˜๊ณ  ์‰ฝ๊ฒŒ ์ •๋ ฌํ•œ ๋ชจ์Šต์ด๋‹ค. ์ปจํ…Œ์ด๋„ˆ์— flex-direction:column; ์„ ๋ถ€์—ฌํ•˜๊ณ , ์ฒซ ๋ฒˆ์งธ Flex ์•„์ดํ…œ์— align-self:flex-end;๋ฅผ, ๋„ค ๋ฒˆ์งธ Flex ์•„์ดํ…œ์— align-self:flex-start; ์„ ์ฃผ์–ด ๋ฐฐ์น˜ํ•˜์˜€๋‹ค. ๊ฐ’์ด ๋ถ€์—ฌ๋˜์ง€ ์•Š์€ ๋‘ ๋ฒˆ์งธ์™€ ์„ธ ๋ฒˆ์งธ ์•„์ดํ…œ ์š”์†Œ๋Š” align-self:auto;๊ฐ€ ๋˜์–ด, ์ปจํ…Œ์ด๋„ˆ์˜ align-items์˜ ๊ธฐ๋ณธ๊ฐ’์ธ stretch ์†์„ฑ์„ ๋ถ€์—ฌ๋ฐ›์€ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.
notion imagenotion image
.container{ display: flex; flex-direction: column; } .item:nth-child(1){align-self: flex-end;} .item:nth-child(4){align-self: flex-start;}

9.2. order

order ์†์„ฑ์€ ์•„์ดํ…œ ์š”์†Œ๋“ค์˜ ์ˆœ์„œ๋ฅผ ๊ฒฐ์ •ํ•˜๋Š” ์†์„ฑ์ด๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ flex๋Š” ์ž‘์„ฑํ•œ ์ˆœ์„œ๋Œ€๋กœ ๋‚˜์—ด๋˜์ง€๋งŒ, order ์†์„ฑ์„ ์‚ฌ์šฉํ•˜์—ฌ ์•„์ดํ…œ๋“ค์˜ ์ˆœ์„œ๋ฅผ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋‹ค.
order์˜ ํŠน์ง•
  • ๊ธฐ๋ณธ๊ฐ’์€ 0์ด๋ฉฐ, ์Œ์ˆ˜์™€ ์–‘์ˆ˜๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ๊ฐ’์ด ์ž‘์„์ˆ˜๋ก ์šฐ์„ ์ˆœ์œ„๊ฐ€ ์ ์šฉ๋˜์–ด ์Œ์ˆ˜ โ†’ 0 โ†’ ์–‘์ˆ˜ ์ˆœ์„œ๋กœ ํ‘œ์‹œ๋œ๋‹ค.
  • flex-direction ์†์„ฑ์˜ ๋ฐฉํ–ฅ๊ฐ’(row, row-reverse, column, column-reverse)์„ ๊ธฐ์ค€์œผ๋กœ ๋‚ฎ์€ ์ˆซ์ž๋ฅผ ๋จผ์ € ๋ฐฐ์น˜ํ•œ๋‹ค.
  • HTML ๊ตฌ์กฐ์™€ ์ƒ๊ด€์—†์ด ์ˆœ์„œ๋ฅผ ์‹œ๊ฐ์ ์œผ๋กœ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, HTML ์ž์ฒด์˜ ๊ตฌ์กฐ๋ฅผ ๋ฐ”๊พธ๋Š” ๊ฒƒ์€ ์•„๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์Šคํฌ๋ฆฐ๋ฆฌ๋”๊ฐ€ ์ฝ์„ ๋•Œ๋Š” order๊ฐ’์ด ์ ์šฉ๋˜์ง€ ์•Š๊ณ  HTML ๋งˆํฌ์—… ์ˆœ์„œ๋Œ€๋กœ ์ฝํžŒ๋‹ค.
ย 
์•„๋ž˜๋Š” flex-direction: row; ์™€ flex-direction: column;์—์„œ order ๊ฐ’์„ ์ ์šฉํ•˜์ง€ ์•Š์•˜์„ ๋•Œ์™€ ์ ์šฉํ–ˆ์„ ๋•Œ์˜ ๋ชจ์Šต์ด๋‹ค.
ย 
flex-direction: row;
  • order ๊ฐ’์„ ์ ์šฉํ•˜์ง€ ์•Š์€ ๋ชจ์Šต
notion imagenotion image
ย 
  • order๊ฐ’์„ ์ ์šฉํ•œ ๋ชจ์Šต
notion imagenotion image
.item:nth-child(1) {order: 2;} .item:nth-child(2) {order: 3;} .item:nth-child(3) {order: 1;}
ย 
flex-direction: column;
  • order ๊ฐ’์„ ์ ์šฉํ•˜์ง€ ์•Š์€ ๋ชจ์Šต
notion imagenotion image
ย 
  • order๊ฐ’์„ ์ ์šฉํ•œ ๋ชจ์Šต
notion imagenotion image
ย 
order์˜ ์‚ฌ์šฉ ์˜ˆ์‹œ
  1. ๋‚ ์งœ์™€ ์ œ๋ชฉ, ๋‚ด์šฉ์ด ์žˆ๋Š” ์นด๋“œ ๋””์ž์ธ์„ ๋งŒ๋“ ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜์ž. ์•„๋ž˜์˜ ์ด๋ฏธ์ง€์ฒ˜๋Ÿผ ๋‚ ์งœ๊ฐ€ ์ œ๋ชฉ๋ณด๋‹ค ๋จผ์ € ์œ„์น˜ํ•˜๊ฒŒ ํ•  ๋•Œ, ๊ธฐ๋ณธ ์ˆœ์„œ๋กœ ๋ฐฐ์น˜ํ•œ๋‹ค๋ฉด ์Šคํฌ๋ฆฐ ๋ฆฌ๋”๋Š” ๋‚ ์งœ, ์ œ๋ชฉ, ๋‚ด์šฉ ์ˆœ์œผ๋กœ ์ฝ์„ ๊ฒƒ์ด๋‹ค. ํ•˜์ง€๋งŒ ์‚ฌ์šฉ์ž๋Š” ๊ฐ€์žฅ ์ค‘์š”ํ•œ ์ œ๋ชฉ์„ ๋จผ์ € ์ฝ์€ ํ›„ ๋‚ ์งœ๋ฅผ ์ฝ๊ธฐ๋ฅผ ์„ ํ˜ธํ•œ๋‹ค. ์ด๋Ÿด ๊ฒฝ์šฐ, ๋‚ ์งœ์— order:-1์„ ์ฃผ์–ด ์‹œ๊ฐ์  ์ˆœ์„œ๋งŒ ๋ฐ”๊ฟ”์„œ ์Šคํฌ๋ฆฐ ๋ฆฌ๋”๊ฐ€ ์ฝ๋Š” ์ˆœ์„œ๋ฅผ ๋ณ€๊ฒฝํ•˜์ง€ ์•Š๋„๋ก ํ•  ์ˆ˜ ์žˆ๋‹ค.
ย 
notion imagenotion image
ย 
  1. ์•„๋ž˜์™€ ๊ฐ™์€ ๊ฒฝ์šฐ์—๋„ order ์†์„ฑ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.
์ด๋ฏธ ๋งŒ๋“ค์–ด์ง„ ๋ชจ๋“ˆ์„ ์‚ฌ์šฉํ•˜์—ฌ ์›น์„ ๊ตฌ์„ฑํ•œ๋‹ค๋ฉด ์ดˆ๊ธฐ์—๋Š” ์•„๋ž˜์™€ ๊ฐ™์€ ๋ฐฐ์น˜๊ฐ€ ๋œ๋‹ค. ๋งˆํฌ์—… ์ˆœ์„œ๊ฐ€ header๋ถ€ํ„ฐ footer๊นŒ์ง€ ์ฐจ๋ก€๋Œ€๋กœ ๋˜์–ด์žˆ์œผ๋ฏ€๋กœ, ๊ฐ ์š”์†Œ์˜ ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•ด์ฃผ์–ด๋„ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ˆœ์„œ๋Š” ๋ฐ”๋€Œ์ง€ ์•Š๋Š”๋‹ค.
notion imagenotion image
ย 
  • order ์†์„ฑ์„ ์ฃผ์ง€ ์•Š์•˜์„ ๋•Œ
์š”์†Œ๋“ค์˜ ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•ด์ฃผ์—ˆ์ง€๋งŒ, ๋งˆํฌ์—… ์ˆœ์„œ๋Œ€๋กœ ๋ฐฐ์น˜๋˜๊ธฐ ๋•Œ๋ฌธ์— order ์†์„ฑ์„ ์ฃผ์ง€ ์•Š๋Š”๋‹ค๋ฉด ๊ธฐ๋ณธ์ ์ธ ์ˆœ์„œ๋ฅผ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์—†๋‹ค.
notion imagenotion image
ย 
  • order ์†์„ฑ์„ ์ฃผ์—ˆ์„ ๋•Œ
ํ˜„์žฌ main ๋ถ€๋ถ„์„ ๊ฐ€์šด๋ฐ๋กœ ์˜ฎ๊ธฐ๋ ค๊ณ  ํ•œ๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ aside-a, main, aside-b ์š”์†Œ์— ๊ฐ๊ฐ order๋ฅผ ์ฃผ๋ฉด ๋ฐฐ์น˜๊ฐ€ ๋˜์ง€๋งŒ, ๊ธฐ๋ณธ์ ์œผ๋กœ order ๊ฐ’์„ 1์ด๋ผ๋„ ์ฃผ๊ฒŒ ๋˜๋ฉด, order ๊ฐ’์ด ์—†๋Š” ์†์„ฑ์ด ๋” ์šฐ์„ ์‹œ๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋งˆํฌ์—…์ƒ ์•„๋ž˜์— ์žˆ๋Š” footer ๋ถ€๋ถ„์—๋„ order ๊ฐ’์„ ์ฃผ์–ด์•ผ ํ•œ๋‹ค. ์ฆ‰ ์šฐ๋ฆฌ๊ฐ€ ์›ํ•˜๋Š” ์ˆœ์„œ๋Œ€๋กœ ๊ฐ ์š”์†Œ์— order๋ฅผ 1, 2, 3, 4๋ฅผ ์ฃผ๊ฒŒ ๋˜๋ฉด, ์šฐ๋ฆฌ๊ฐ€ ์›ํ•˜๋Š” ๋ ˆ์ด์•„์›ƒ์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค.
notion imagenotion image
.main { width: 60%; order: 2; } .aside { width: 20%; } .aside.aside-a { order: 1; } .aside.aside-b { order: 3; } .footer { order: 4; }

9.3. z-index

flex์—์„œ๋„ z-index ์†์„ฑ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ์–ด๋–ค ์š”์†Œ์— z-index์˜ ๊ฐ’์ด 1์ด๋ผ๋„ ์ฃผ์–ด์ง„๋‹ค๋ฉด ๋งˆ์น˜ ๋‹ค๋ฅธ ์š”์†Œ๋ฅผ ๋ฎ์–ด ์”Œ์šฐ๋Š” ๊ฒƒ๊ณผ ๊ฐ™์€ ๋ชจ์Šต์„ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค.
notion imagenotion image
.main { width: calc(60% - 16px); order: 2; z-index: 1; transform: scale(1.5); opacity: 0.8; }

10. IE ์ง€์›์„ ์œ„ํ•œ Flex

10.1. -ms- prefix ์‚ฌ์šฉ ์˜ˆ์‹œ

IE์—์„œ ์ง€์›ํ•˜์ง€ ์•Š๋Š” Flex ์†์„ฑ
flex-flox , justify-content: space-around , align-self , align-content ์˜ 4๊ฐ€์ง€ ์†์„ฑ๋“ค์€ ํ˜„์žฌ ์ง€์›ํ•˜๊ณ  ์žˆ์ง€ ์•Š๋‹ค. ๋˜ flex-grow , flex-shrink , flex-basis์˜ 3๊ฐ€์ง€ ์†์„ฑ๋“ค์€ ๋‹จ์ถ• ์†์„ฑ์ธ -ms-flex: 0 1 auto; ๋ฅผ ํ†ตํ•ด ์ง€์›ํ•˜๊ณ  ์žˆ๋‹ค. (IE10๋ฒ„์ „ ์—์„œ๋Š” -ms-flex: 0 0 auto; ๋ฅผ ํ†ตํ•ด ์ง€์›ํ•˜๊ณ  ์žˆ๋‹ค.)
Flex ์†์„ฑ IE ์ง€์› ๋Œ€์‘ํ‘œ
์†์„ฑ
IE ์ง€์›
display: flex;
display: -ms-flexbox;
flex-grow
-ms-flex
flex-direction
-ms-flex-direction
flex-wrap
-ms-flex-wrap
order
-ms-flex-order
justify-content
-ms-flex-pack
align-items
-ms-flex-align

10.2. IE์—์„œ์˜ Flex ์ด์Šˆ

์ฃผ์˜ํ•ด์•ผ ํ•  Flex ์ด์Šˆ
IE 10/11 ๋ฒ„์ „์—์„œ Flex๋ฅผ ์‚ฌ์šฉ ํ•  ๋•Œ ์ƒ๊ฐ๋Œ€๋กœ ์ž‘๋™๋˜์ง€ ์•Š๋Š” ์ด์Šˆ๋“ค๊ณผ ๋งž๋‹ฅ๋œจ๋ฆด ์ˆ˜ ์žˆ๋Š”๋ฐ, ๊ทธ ์ค‘ ๋ช‡ ๊ฐ€์ง€๋ฅผ ์†Œ๊ฐœํ•˜๊ฒ ๋‹ค.
  • IE 10๊ณผ 11 ๋ฒ„์ „์—์„œ flex-basis ์‚ฌ์šฉ ์‹œ์— box-sizing: border-box;๊ฐ€ ์ธ์‹๋˜์ง€ ์•Š๋Š”๋‹ค. IE 10/11์—์„œ๋Š” flex-basis๋กœ flex item์˜ ํฌ๊ธฐ๋ฅผ ์ •ํ•  ๋•Œ, flex item์˜ ํฌ๊ธฐ๋ฅผ ํ•ญ์ƒ item์˜ ์ฝ˜ํ…์ธ  ํฌ๊ธฐ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์žก๋Š”๋‹ค. box-sizing: border-box; ์†์„ฑ์„ ์ฃผ์–ด๋„ ๋ฐ”๋€Œ์ง€ ์•Š๋Š”๋‹ค. ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ• ์ค‘ ํ•˜๋‚˜๋Š” flex item์„ ๊ฐ์‹ธ๋Š”(wrapper) ์š”์†Œ๋ฅผ ์ถ”๊ฐ€ํ•ด ์ฃผ๋Š” ๊ฒƒ์ด๋‹ค. ์ด ๋•Œ ์š”์†Œ๋Š” border๋‚˜ padding๊ฐ’์ด ์—†์–ด์•ผ ํ•œ๋‹ค.
  • IE 10/11์—์„œ min-height ์†์„ฑ์„ flex container์— ์‚ฌ์šฉ ์‹œ, ์ž์‹ ํƒœ๊ทธ์ธ flex item์€ ๋ถ€๋ชจ ํƒœ๊ทธ์ธ flex container์˜ ํฌ๊ธฐ๋ฅผ ์ธ์‹ํ•˜์ง€ ๋ชปํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, flex item์„ ์ˆ˜์ง ์ •๋ ฌํ•˜๊ณ ์ž ํ•  ๋•Œ, ๋ถ€๋ชจ์ธ flex container์˜ ๋†’์ด๊ฐ€ ์ธ์‹๋˜์–ด์•ผ ํ•˜๋Š”๋ฐ, item๋“ค์ด ๋†’์ด๋ฅผ ์ธ์‹ํ•˜์ง€ ๋ชปํ•˜๊ฒŒ ๋œ๋‹ค. ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ๋Š” flex container๋ฅผ ๊ฐ์‹ธ๋Š” ๋˜ ๋‹ค๋ฅธ flex container์š”์†Œ(wrapper)๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ์ด๋•Œ flex container๋ฅผ ๊ฐ์‹ธ๋Š” ๋ถ€๋ชจ ์š”์†Œ๋Š” column direction ์†์„ฑ์œผ๋กœ ์ง€์ •ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค.
ย 
flex ์ด์Šˆ ํ™•์ธ ์‚ฌ์ดํŠธ
์ด ์™ธ์—๋„ IE 10/11 ๋ฒ„์ „์—์„œ flex ์‚ฌ์šฉ์—๋Š” ์—ฌ๋Ÿฌ ์ด์Šˆ๊ฐ€ ์žˆ๋‹ค. ๋‹ค์Œ์€ flex ์ด์Šˆ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” ์‚ฌ์ดํŠธ์ด๋‹ค.

11. ์„ฑ๋ฐฐ ๋ ˆ์ด์•„์›ƒ ๊ทธ๋ฆฌ๊ธฐ

11.1. Flex ์†์„ฑ์„ ์ด์šฉํ•˜์—ฌ ๊ธฐ๋ณธ ์„ฑ๋ฐฐ ๋ ˆ์ด์•„์›ƒ ๊ตฌํ˜„ํ•˜๊ธฐ

์ตœ์ข…์ฝ”๋“œ
<!DOCTYPE html> <html lang="ko"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>์„ฑ๋ฐฐ๋ ˆ์ด์•„์›ƒ1</title> <link rel="stylesheet" as="style" crossorigin href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css" /> <style> :root { --dark: #504975; --white: #ffffff; --background: #fbfbff; --primary: #7661e2; --light: #eceafe; } * { font-family: Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif; } body { height: 100%; padding: 10%; box-sizing: border-box; } .container { width: 70%; height: 300px; padding: 22px; margin: 0 auto; border: 1px solid var(--dark); border-radius: 20px; background: #fff; box-shadow: 0px 4px 12px 0px #51459F14; } .item { height: 40px; /* padding: 0px ; ์ฝ˜ํ…์ธ ์— ๋”ฐ๋ผ ์กฐ์ ˆํ•ด์ฃผ์„ธ์š” */ border: 1px solid var(--dark); border-radius: 20px; background-color: var(--primary); color: var(--white); box-shadow: 0px 4px 15px 0px #51459F14; text-align: center; vertical-align: middle; line-height: 2.5; word-break: keep-all; } .wrap{ display: flex; flex-flow: row wrap; gap: 0.5rem; margin: 0.5rem 0; } .main-content, .left-sidebar, .right-sidebar{ background-color: var(--light); color: var(--dark); padding: 80px 0; } .main-content{ flex-grow: 2; order: 2; } .left-sidebar{ flex-grow: 1; order: 1; } .right-sidebar{ flex-grow: 1; order: 3; } </style> </head> <body> <div class="container"> <div class="item header">Header</div> <div class="wrap"> <div class="item main-content">Main Content</div> <div class="item left-sidebar">Left Sidebar</div> <div class="item right-sidebar">Right Sidebar</div> </div> <div class="item footer">Footer</div> </div> </body> </html>
notion imagenotion image
  1. ์ปจํ…Œ์ด๋„ˆ ์•ˆ์— ์š”์†Œ๋“ค์„ ๋„ฃ์œผ๋ฉด ๋งˆํฌ์—…์ˆœ์„œ์— ๋”ฐ๋ผ ์ž๋™์ ์œผ๋กœ ์œ„์—์„œ ์•„๋ž˜๋กœ ์Œ“์ด๊ฒŒ ๋œ๋‹ค. ์šฐ๋ฆฌ๋Š” content, sidebar์š”์†Œ๋“ค์„ ๋‚˜๋ž€ํžˆ ๋ฐฐ์น˜ํ•˜๋Š” ๊ฒƒ์ด ๋ชฉ์ ์ด๋‹ค.
notion imagenotion image
<div class="container"> <div class="header">Header</div> <div class="main-content">Main Content</div> <div class="left-sidebar">Left Sidebar</div> <div class="right-sidebar">Right Sidebar</div> <div class="footer">Footer</div> </div>
  1. ๋‚˜๋ž€ํžˆ ๋ฐฐ์น˜ํ•˜๊ณ  ์‹ถ์€ ์š”์†Œ๋“ค์„ wrap์œผ๋กœ ๋ฌถ์–ด์ค€๋‹ค. wrap๋ถ€๋ถ„์— display: flex; ๋ฅผ ์„ ์–ธํ•ด ์คŒ์œผ๋กœ์จ flex-direction๋ฐฉํ–ฅ์ด ์ดˆ๊ธฐ๊ฐ’์ธ row๋กœ ์ •๋ ฌ๋œ๋‹ค. ๋˜ํ•œ flex์†์„ฑ์œผ๋กœ์ธํ•ด ์•ˆ์˜ ์š”์†Œ๋“ค์ด ์ฝ˜ํ…์ธ ๊ฐ€ ์ฐจ์ง€ํ•˜๋Š” ๋งŒํผ์˜ ๋„ˆ๋น„๋ฅผ ๊ฐ–๋Š”๋‹ค.
notion imagenotion image
<div class="container"> <div class="header">Header</div> <div class="wrap"> <div class="main-content">Main Content</div> <div class="left-sidebar">Left Sidebar</div> <div class="right-sidebar">Right Sidebar</div> </div> <div class="footer">Footer</div> </div>
.wrap{ display: flex; }
  1. ์•„์ดํ…œ ์š”์†Œ๋Š” ์œˆ๋„์šฐ ์ฐฝ ํฌ๊ธฐ์— ๋”ฐ๋ผ์„œ ์ž‘์•„์ง€๊ธฐ๋„ ํ•˜๊ณ  ์ปค์ง€๊ธฐ๋„ ํ•œ๋‹ค. ์ด๋•Œ ๋น„์œจ์„ ์„ค์ •ํ•ด ์ฃผ๊ธฐ ์œ„ํ•ด ๋‚จ์€ ์—ฌ๋ฐฑ์„ ๋‚˜๋ˆ  ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋„๋ก ์ˆซ์ž๋ฅผ ์ง€์ •ํ•ด์ค€๋‹ค. Main Content๊ฐ€ ๊ฐ€์žฅ ํฐ ๋น„์œจ์„ ์ฐจ์ง€ํ•ด์•ผ ํ•˜๋ฏ€๋กœ flex-grow:2; ๋ฅผ ์ง€์ •ํ•ด์ฃผ๊ณ  ๋‚˜๋จธ์ง€๋Š” flex-grow:1; ๋กœ ์ง€์ •ํ•œ๋‹ค.
notion imagenotion image
.main-content{ flex-grow: 2; } .left-sidebar{ flex-grow: 1; } .right-sidebar{ flex-grow: 1; }
  1. ๋งˆํฌ์—… ์ˆœ์„œ์— ๋”ฐ๋ผ Left Sidebar, Main Content, Right Sidebar ์ˆœ์œผ๋กœ ์Œ“์ด๊ฒŒ ๋˜๋Š”๋ฐ, Main Content๋ฅผ ๊ฐ€์šด๋ฐ๋กœ ์˜ค๊ฒŒ ๋ฐฐ์น˜ํ•ด์•ผ ํ•˜๋ฏ€๋กœ order์†์„ฑ์„ ๊ฐ๊ฐ ์ •ํ•ด์ฃผ์–ด ๋ธŒ๋ผ์šฐ์ € ์ƒ์— ํ‘œ์‹œ๋˜๋Š” ๋ชจ์Šต์„ ์ง€์ •ํ•˜์—ฌ ์™„์„ฑํ•œ๋‹ค.
notion imagenotion image
.main-content { flex-grow: 2; order: 2; } .left-sidebar { flex-grow: 1; order: 1; } .right-sidebar { flex-grow: 1; order: 3; }

11.2. Flex ์†์„ฑ์„ ์ด์šฉํ•˜์—ฌ ๋ณ€ํ˜•๋œ ์„ฑ๋ฐฐ ๋ ˆ์ด์•„์›ƒ ๊ตฌํ˜„ํ•˜๊ธฐ

์ตœ์ข…์ฝ”๋“œ
<!DOCTYPE html> <html lang="ko"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Flexbox ์„ฑ๋ฐฐ๋ ˆ์ด์•„์›ƒ2</title> <link rel="stylesheet" as="style" crossorigin href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css" /> <style> :root { --dark: #504975; --white: #ffffff; --background: #fbfbff; --primary: #7661e2; --light: #eceafe; } * { font-family: Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif; } body { height: 100%; padding: 10%; box-sizing: border-box; } .container { width: 70%; padding: 22px; margin: 0 auto; border: 1px solid var(--dark); border-radius: 20px; background: #fff; box-shadow: 0px 4px 12px 0px #51459F14; } .item { height: 40px; /* padding: 0px ; ์ฝ˜ํ…์ธ ์— ๋”ฐ๋ผ ์กฐ์ ˆํ•ด์ฃผ์„ธ์š” */ border: 1px solid var(--dark); border-radius: 20px; background-color: var(--primary); color: var(--white); box-shadow: 0px 4px 15px 0px #51459F14; text-align: center; vertical-align: middle; line-height: 2.5; word-break: keep-all; } .wrap{ display: flex; flex-flow: row wrap; gap: 0.5rem; margin: 0.5rem 0; } .content, .sidebar{ background-color: var(--light); color: var(--dark); } .content{ flex-grow: 1; order: 2; padding: 30px 0; } .sidebar{ flex-grow: 1; order: 1; padding: 55px 0; } .footer{ width: 66%; margin-left: auto; margin-top: -50px; } </style> </head> <body> <div class="container"> <div class="item header">Header</div> <div class="wrap"> <div class="item content">Content</div> <div class="item content">Content</div> <div class="item sidebar">Sidebar</div> </div> <div class="item footer">Footer</div> </div> </body> </html>
notion imagenotion image
  1. ๊ธฐ๋ณธ html ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ด๋ณธ๋‹ค. ํฐ container ์•ˆ์— header, content, footer ์„ธ๊ฐ€์ง€๋กœ ๋‚˜๋‰œ ์ƒํƒœ์—์„œ ์ œ์ž‘์„ ํ•œ๋‹ค.
    1. notion imagenotion image
      <div class="container"> <div class="header">Header</div> <div class="content">Content</div> <div class="footer">Footer</div> </div>
  1. content๋ฅผ ์„ธ๋ถ„ํ™”ํ•˜์—ฌ 2๊ฐœ์˜ content์™€ 1๊ฐœ์˜ sidebar๊ฐ€ ์ƒˆ๋กœ์šด ์š”์†Œ๋กœ ๋‚˜์˜ฌ ์ˆ˜ ์žˆ๊ฒŒ๋” ๋ถ„ํ• ํ•˜๊ณ  ์ƒ์œ„์š”์†Œ๋กœ ํ•˜๋‚˜์˜ wrap์œผ๋กœ ๋ฌถ์–ด์ค€๋‹ค. ์šฐ๋ฆฌ๋Š” wrap์š”์†Œ์˜ flex ๋ฅผ ์ด์šฉํ•˜์—ฌ ์ž์œ ๋กญ๊ฒŒ ๋ณ€ํ˜•๋œ ๋ ˆ์ด์•„์›ƒ์„ ๋ฐฐ์น˜ํ•˜๋Š” ๊ฒƒ์ด ๋ชฉ์ ์ด๋‹ค.
notion imagenotion image
<div class="container"> <div class="header">Header</div> <div class="wrap"> <div class="content">Content</div> <div class="content">Content</div> <div class="sidebar">Sidebar</div> </div> <div class="footer">Footer</div> </div>
  1. content ์™€ sidebar ์š”์†Œ๋“ค์˜ ์ƒ์œ„ ๋ถ€๋ชจ ์š”์†Œ์ธ wrap์— display:flex ์†์„ฑ์„ ๋ถ€์—ฌํ•˜๊ณ  ๊ฐ ์š”์†Œ ๊ฐ„ ์—ฌ๋ฐฑ๊ณผ ๊ฐ„๊ฒฉ์„ ๋ถ€์—ฌํ•œ๋‹ค. flex์˜ ํ•˜์œ„ ์š”์†Œ๋“ค์˜ ๊ฐ„๊ฒฉ์„ ์กฐ์ •ํ•  ๋•Œ๋Š” gap ์†์„ฑ์„ ์ด์šฉํ•˜๋ฉฐ ๋ถ€๋ชจ ์š”์†Œ์ธ wrap ์ž์‹ ์˜ ์—ฌ๋ฐฑ์„ ์กฐ์ •ํ•  ๋•Œ๋Š” margin์„ ์ด์šฉํ•œ๋‹ค.
    1. notion imagenotion image
      .wrap{ display: flex; flex-flow: row wrap; gap: 0.5rem; margin: 0.5rem 0; }
  1. contents์˜ ์Šคํƒ€์ผ์„ ์กฐ์ •ํ•ด๋ณธ๋‹ค. flex-glow ์†์„ฑ์œผ๋กœ ์—ฌ๋ฐฑ์„ ๋™์ผํ•˜๊ฒŒ ์ฃผ๋„๋ก ํ”„๋กœํผํ‹ฐ ๊ฐ’์„ 1๋กœ ํ†ต์ผํ•ด์ฃผ๊ณ , ๋งˆํฌ์—… ์ˆœ์„œ ์ƒ content๊ฐ€ ๊ฐ€์žฅ ๋จผ์ € ๋‚˜์™€์•ผ ํ•˜์ง€๋งŒ ๋””์ž์ธ ์ƒ์œผ๋กœ๋Š” sidebar๊ฐ€ ์•ž์œผ๋กœ ๋‚˜์˜ค๋„๋ก ์„ค์ •ํ•ด์ฃผ์–ด์•ผ ํ•จ์œผ๋กœ order๊ฐ’์„ sidebar๋ณด๋‹ค ๋†’์€ ์–‘์ˆ˜์˜ ์ˆซ์ž๋กœ ํ‘œํ˜„ํ•œ๋‹ค. (ํŒจ๋”ฉ ๊ฐ’์€ ์ž„์˜์˜ ๋†’์ด๋ฅผ ์„ค์ •ํ•˜๊ธฐ ์œ„ํ•˜์—ฌ ์ž„์˜์˜ ๊ฐ’์„ ์ง€์ •ํ•˜์˜€๋‹ค)
    1. notion imagenotion image
      .content{ flex-grow: 1; order: 2; padding: 30px 0; }
    2. sidebar์˜ ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•ด์ค€๋‹ค. content์™€ ๊ฐ™์€ ์—ฌ๋ฐฑ์„ ๊ฐ€์ง€๊ธฐ ์œ„ํ•˜์—ฌ flex-glow๊ฐ’์„ 1๋กœ ํ†ต์ผํ•˜์˜€๊ณ , content๋ณด๋‹ค ๋ ˆ์ด์•„์›ƒ ์ƒ ์•ž์œผ๋กœ ๋ฐฐ์น˜ํ•˜๊ธฐ ์œ„ํ•˜์—ฌ order๊ฐ’์„ content์˜ order๊ฐ’ 2๋ณด๋‹ค ์ž‘์€ 1๋กœ ์ž‘์—…ํ•ด๋ณธ๋‹ค. content์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ content๋ณด๋‹จ ๋†’์€ ์ž„์˜์˜ ๋†’์ด๊ฐ’์„ ์„ค์ •ํ•˜๊ธฐ ์œ„ํ•˜์—ฌ ํŒจ๋”ฉ๊ฐ’์„ ์ฃผ์—ˆ๋‹ค.
    3. notion imagenotion image
      .sidebar{ flex-grow: 1; order: 1; padding: 55px 0; }
    4. footer์˜ ์Šคํƒ€์ผ๋ง ์ฐจ๋ก€์ด๋‹ค. footer๋ฅผ content์˜ ๋ฐ”๋กœ ์•„๋žซ๊ณต๊ฐ„์œผ๋กœ ์ด๋™์‹œํ‚ค๊ธฐ ์œ„ํ•ด์„œ ์ „์ฒด content ๊ฐ’์„ ์œ ๋™์ ์œผ๋กœ ์ ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก footer ์˜ width ๋ฅผ ํผ์„ผํ‹ฐ์ง€์˜ ๊ฐ’์œผ๋กœ ๋„ฃ๋Š”๋‹ค. ๊ทธ๋ฆฌ๊ณ  footer๋Š” ๋ธ”๋ก ์š”์†Œ์ด๋ฏ€๋กœ footer์˜ ํ•ด๋‹น ์ค„ ์ „์ฒด๋ฅผ ์ฐจ์ง€ํ•˜๋Š” margin์˜ ์™ผ์ชฝ๊ฐ’์„ auto๋กœ ๋ถ€์—ฌํ•˜์—ฌ footer์˜ ์™ผ์ชฝ ์—ฌ๋ฐฑ์„ ์ž๋™์œผ๋กœ ๊ฐ€์ ธ๊ฐˆ ์ˆ˜ ์žˆ๋„๋ก ์ž‘์„ฑํ•œ๋‹ค.
    5. notion imagenotion image
      .footer{ width: 66%; margin-left: auto; }
    6. ๋งˆ์ง€๋ง‰ ๋‹จ๊ณ„์ด๋‹ค. footer์—ฌ๋ฐฑ์— ์—ฌ๋ฐฑ์˜ ๋ฐ˜๋Œ€๋ผ๋Š” ์˜๋ฏธ์ธ nagative margin์„ ์ ์šฉํ•˜์—ฌ footer์š”์†Œ๋ฅผ ์œ„์ชฝ์œผ๋กœ ๋Œ์–ด์˜ฌ๋ ค์ฃผ๋ฉด flex์˜ ๋ณ€ํ˜•๋œ ์„ฑ๋ฐฐ๋ ˆ์ด์•„์›ƒ ์ž‘์„ฑ์ด ๋๋‚œ๋‹ค.
    7. notion imagenotion image
      .footer{ width: 66%; margin-left: auto; margin-top: -50px; }
      ย 
ย