roqkf

[CSS] Flexbox ๋ณธ๋ฌธ

๐Ÿ’ป Development/CSS

[CSS] Flexbox

ahyeon7 2022. 11. 27. 01:11

float

  • ์ด๋ฏธ์ง€์™€ ํ…์ŠคํŠธ๋“ค์„ ์–ด๋–ป๊ฒŒ ๋ฐฐ์น˜ํ•  ๊ฑด์ง€ ์ •๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ๋‚˜ํƒ€๋‚จ
  • float:left = ์ด๋ฏธ์ง€๊ฐ€ ์™ผ์ชฝ์œผ๋กœ ์ •๋ ฌ๋˜๊ณ  ๋‚˜๋จธ์ง€ ํ…์ŠคํŠธ
  • float:center = ์ด๋ฏธ์ง€๊ฐ€ ๊ฐ€์šด๋ฐ
  • float:right = ์ด๋ฏธ์ง€๊ฐ€ ์˜ค๋ฅธ์ชฝ

Flaxbox

  • ์ปจํ…Œ์ด๋„ˆ์— ์ ์šฉํ•˜๋Š” ์†์„ฑ๊ฐ’์ด ์กด์žฌ, ์ปจํ…Œ์ด๋„ˆ ์•ˆ์˜ ์•„์ดํ…œ์ด ์ ์šฉํ•˜๋Š” ์†์„ฑ๊ฐ’์ด ์กด์žฌ
  • ์ค‘์‹ฌ์ถ•(main axis)๊ณผ ๋ฐ˜๋Œ€์ถ•(cross axis)์ด ์žˆ์Œ

- container ์†์„ฑ

1. display (flex ์‚ฌ์šฉ์„ ์œ„ํ•ด ์„ ์–ธ)

- display: flex;

2. flex-direction (๋ฐฉํ–ฅ)

- flex-direction: row; (๊ธฐ๋ณธ)
- flex-direction: row-reverse;
- flex-direction: column;
- flex-direction: column-reverse;

3. flex-wrap

- flex-wrap: nowrap; (๊ธฐ๋ณธ)
- flex-wrap: wrap; (๊ณต๊ฐ„ ๋ถ€์กฑํ•˜๋ฉด ๋‹ค์Œ ๋ผ์ธ์œผ๋กœ ๋„˜์–ด๊ฐ€๊ฒŒ ๋จ)  

4. flex-flow (flex-direction + flex-wrap)

5. justify-conent (์ค‘์‹ฌ์ถ•์—์„œ ์•„์ดํ…œ์„ ์–ด๋–ป๊ฒŒ ๋ฐฐ์น˜ํ•  ๊ฑด์ง€)

- justify-conent: flex-start; (๊ธฐ๋ณธ)
- justify-conent: flex-end;
- justify-conent: center;
- justify-conent: space-around;
- justify-conent: space-evenly;
- justify-conent: space-between;

6. align-items (๋ฐ˜๋Œ€์ถ•์—์„œ ์•„์ดํ…œ์„ ์–ด๋–ป๊ฒŒ ํ•  ๊ฑด์ง€ ๊ฒฐ์ •)

- aling-items: baseline; ๊ท ๋“ฑํ•˜๊ฒŒ ํ•ด ์คŒ

7. aling-content (๋ฐ˜๋Œ€์ถ•์—์„œ ์•„์ดํ…œ์„ ์–ด๋–ป๊ฒŒ ๋ฐฐ์น˜ํ•  ๊ฑด์ง€)

- aling-content: start
- aling-content: end;
- aling-content: center;
- aling-content: space-around;
- aling-content: space-evenly;
- aling-content: space-between;

- item ์†์„ฑ

1. order (์•„์ดํ…œ์˜ ์ˆœ์„œ)

2. flex-grow (์ปจํ…Œ์ด๋„ˆ์˜ ํฌ๊ธฐ๊ฐ€ ์ปค์กŒ์„ ๋•Œ ์•„์ดํ…œ์˜ ๋Š˜์–ด๋‚˜๋Š” ๋น„์œจ์„ ์ง€์ •)

- flex-grow: 0; (๊ธฐ๋ณธ)

3. flex-shrink (์ปจํ…Œ์ด๋„ˆ์˜ ํฌ๊ธฐ๊ฐ€ ์ž‘์•„์กŒ ๋•Œ ์•„์ดํ…œ์˜ ์ค„์–ด๋“œ๋Š” ๋น„์œจ์„ ์ง€์ •)

- flex-shrink: 0; (๊ธฐ๋ณธ)

4. flex-basis

- flex-basis: auto; (๊ธฐ๋ณธ, grow๋‚˜ shrink์— ๋งž์ถฐ์„œ ๋ณ€ํ˜•)
- flex-basis: ๊ฐ’; (์ปจํ…Œ์ด๋„ˆ์˜ width์— ๋”ฐ๋ผ์„œ ์ปค์งˆ ๋•Œ๋„, ์ž‘์•„์งˆ ๋•Œ ๋ณ€ํ˜•)

5. align-slef (์•„์ดํ…œ๋ณ„๋กœ ์•„์ดํ…œ์„ ์ •๋ ฌ)

 

 

๋งˆ์ง€๋ง‰์œผ๋กœ ์—ฐ์Šต์„ ์œ„ํ•ด

Flexbox Froggy ๊ฒŒ์ž„: https://flexboxfroggy.com/ ๊นŒ์ง€ ํ•˜๊ธฐ!!

'๐Ÿ’ป Development > CSS' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

CSS ์• ๋‹ˆ๋ฉ”์ด์…˜  (0) 2023.01.17
[CSS] ๋ ˆ์ด์•„์›ƒ display  (0) 2022.11.27
[CSS] Selector  (0) 2022.11.27
[CSS] ๋ฐ•์Šค๋ชจ๋ธ  (0) 2022.11.26
[CSS] ๊ธฐ์ดˆ  (0) 2022.11.26