whatisthis?

css. FlexBox (display: flex) - (ไธŠ) ๋ณธ๋ฌธ

WEB STUDY/HTML,CSS

css. FlexBox (display: flex) - (ไธŠ)

thisisyjin 2022. 2. 22. 12:42

FlexBox

 

 

๐Ÿ’ก key points

 

dispaly: flex ์„ ์–ธ

๊ฐ€๋กœ์ •๋ ฌ? ์„ธ๋กœ์ •๋ ฌ? (flex-direction)

๋ฌด์กฐ๊ฑด ํ•œ์ค„์•ˆ์— ๋‹ค ์ •๋ ฌ? (flex-wrap)

์•„์ดํ…œ ์ •๋ ฌ(align-items, justify-contents)

 

 

 


 

1 / ํ”Œ๋ ‰์Šค๋ฐ•์Šค ์‚ฌ์šฉ ์„ ์–ธ

 

- ์ •๋ ฌํ•˜๊ณ ์ž ํ•˜๋Š” ์š”์†Œ๋ฅผ ๊ฐ์‹ธ๋Š” ๋ถ€๋ชจ(=container)์—๊ฒŒ ์„ ์–ธํ•จ.

 

display: flex;

ํ˜น์€

display: inline-flex;

 

flex๋„ ์šฐ์„ ์€ 'box'์˜ ํƒ€์ž…์ด๋‹ค. 

inline-flex๋Š” ์ธ๋ผ์ธ๋ธ”๋Ÿญ๊ณผ ๋น„์Šทํ•˜๊ฒŒ ๋™์ž‘ํ•จ.

 

 

 

 

2 / ๊ฐ€๋กœ or ์„ธ๋กœ ์ •๋ ฌ (flex-direction)

๊ฐ€๋กœ row(default)
์„ธ๋กœ column

 

+) ๊ทธ ์™ธ์—๋„ row-reverse์™€ column-reverse๊ฐ€ ์žˆ๋‹ค.

 

flex๋ฅผ ํ•˜๋ฉด ๋‘๊ฐœ์˜ ์ถ•์ด ์ž๋™์œผ๋กœ ์ƒ๊น€. (๋ˆˆ์— ๋ณด์ด์ง€๋Š” x)

flex-direction์ด ๋ฌด์—‡์ด๋ƒ์— ๋”ฐ๋ผ์„œ ์ถ•์˜ ์œ„์น˜๊ฐ€ ๋‹ฌ๋ผ์ง„๋‹ค.

 

 

๋‘๊ฐœ์˜ ์ถ• ์กด์žฌ

flex-direction์— ๋”ฐ๋ผ main ์ถ•์ด ์ƒ๊ธฐ๊ณ , (default, ์ฆ‰ row์ผ๋• ์ขŒ์šฐ๋กœ)

main์ถ•์˜ ์ˆ˜์ง์œผ๋กœ cross์ถ•์ด ์ƒ๊ธด๋‹ค.

 

๋งŒ์•ฝ reverse๊ฐ€ ๋ถ™์œผ๋ฉด main ์ถ•์ด ์ขŒ->์šฐ๊ฐ€ ์•„๋‹Œ ์ขŒ<-์šฐ๊ฐ€ ๋œ๋‹ค!

 

 

 

 

 

 

3 / ๋ฌด์กฐ๊ฑด ํ•œ์ค„์•ˆ์— ๋‹ค ์ •๋ ฌ? (flex-wrap)

 

 

 

1. nowrap

flex-wrap: nowrap

- wrap ํ•˜์ง€ ์•Š๊ณ , ์ž์‹์˜ ์‚ฌ์ด์ฆˆ๋ฅผ ์ค„์—ฌ์„œ ํ•œ์ค„๋กœ ์ •๋ ฌํ•ด๋ฒ„๋ฆผ.

 

 

2. wrap

flex-wrap: wrap

- wrapํ•ด์„œ ๋งŒ์•ฝ ํ•œ์ค„์— ์ •๋ ฌํ•  ์ˆ˜ ์—†์œผ๋ฉด ์—ฌ๋Ÿฌ์ค„์„ ๋งŒ๋“ฌ.

(์ž์‹์˜ ์‚ฌ์ด์ฆˆ๊ฐ€ ์ค„์–ด๋“ค์ง€ ์•Š์Œ)

 

 

 

 

 

 


 

ref.

 

 

flex - CSS: Cascading Style Sheets | MDN

flex CSS ์†์„ฑ์€ ํ•˜๋‚˜์˜ ํ”Œ๋ ‰์Šค ์•„์ดํ…œ์ด ์ž์‹ ์˜ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์ฐจ์ง€ํ•˜๋Š” ๊ณต๊ฐ„์— ๋งž์ถ”๊ธฐ ์œ„ํ•ด ํฌ๊ธฐ๋ฅผ ํ‚ค์šฐ๊ฑฐ๋‚˜ ์ค„์ด๋Š” ๋ฐฉ๋ฒ•์„ ์„ค์ •ํ•˜๋Š” ์†์„ฑ์ž…๋‹ˆ๋‹ค.

developer.mozilla.org

 

+) reference lecture

 

๊น€๋ฒ„๊ทธ์˜ HTML&CSS๋Š” ์žฌ๋ฐŒ๋‹ค - ๊ตฌ๋ฆ„EDU

HTML&CSS๋ฅผ ํ•œ๋ฒˆ์—! ํƒ„ํƒ„ํ•œ ๊ฐœ๋…์ดํ•ด๋ถ€ํ„ฐ ์‹ค์Šต๊นŒ์ง€ ํ•œ ๊ฐ•์˜๋กœ ๋๋‚ด๊ธฐ, ์‹ค๋ฌด ๊ฐ€๋Šฅํ•œ ์‹ค๋ ฅ์œผ๋กœ ๐Ÿ˜Ž

edu.goorm.io