[CSS] Flex

XIXIยท2022๋…„ 6์›” 3์ผ
0

CSS

๋ชฉ๋ก ๋ณด๊ธฐ
4/5
post-thumbnail

๐ŸŒฑ Flex1

โœ๏ธ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉํ•˜๋‹ˆ

1. ํ”Œ๋ ‰์Šค ๋ฐ•์Šค ์“ธ๊ฑฐ๋‹ค

display: flex;

์š”์†Œ๋“ค์„ ๊ฐ์‹ธ๊ณ  ์žˆ๋Š” ๋ถ€๋ชจํ•œํ…Œ ์ฃผ๊ธฐ

2. ๊ฐ€๋กœ ์ •๋ ฌ > ์„ธ๋กœ ์ •๋ ฌ

display: flex;
flex-direction: row;  

flex ๋ฐฉํ–ฅ ์„ค์ •์‹œ Axis ํ˜•ํƒœ๊ฐ€ ๋‹ฌ๋ผ์ง
row ์„ค์ •์ผ ๊ฒฝ์šฐ: ๊ฐ€๋กœ๋ฐฉํ–ฅ main axis, cross axis(์„ธ๋กœ)
columns ์„ค์ •์ผ ๊ฒฝ์šฐ: ์„ธ๋กœ๋ฐฉํ–ฅ main axis, cross axis(๊ฐ€๋กœ)

3. ๋ฌด์กฐ๊ฑด ํ•œ ์ค„ ์•ˆ์—?

display: flex;
flex-direction: row;  
flex-warp: nowarp;

๊ธฐ๋ณธ๊ฐ’: nowarp ๊ฐ์‹ธ์ง€ ์•Š๊ณ  ์‚ฌ์ด์ฆˆ๋ฅผ ์ค„์—ฌ์„œ๋ผ๋„ ํ•œ ์ค„๋กœ ์ •๋ ฌํ•ด๋ฒ„๋ฆผ
warp์ผ ๊ฒฝ์šฐ, ํ•œ ์ค„์— ์ •๋ ฌ ์–ด๋ ค์šฐ๋ฉด ์—ฌ๋Ÿฌ์ค„ ๋งŒ๋“ค์–ด ์ •๋ ฌ

4. ํ”Œ๋ ‰์Šค ์ •๋ ฌ~~~

justify-content: center;  //์ค‘๊ฐ„์ •๋ ฌ
justify-content: space-between;  //์š”์†Œ๋“ค ์‚ฌ์ด ๊ฐ„๊ฒฉ์„ ๊ฐ™๊ฒŒ
justify-content: space-around;  // ์š”์†Œ๋“ค ์ฃผ๋ณ€ ์‚ฌ์ด ๊ฐ„๊ฒฉ ๊ฐ™๊ฒŒ 

justify-content ์ •๋ ฌ์„ ํ•  ๋•Œ flex-direction ๋ฐฉํ–ฅ์œผ๋กœ ํ•˜๊ณ  ์‹ถ์„ ๋•Œ
aligin-items, aligin-contents coross axis ๋ฐฉํ–ฅ์œผ๋กœ ์ •๋ ฌํ•˜๊ณ  ์‹ถ์„ ๋•Œ
๋ฐ˜๋Œ€ ๋ฐฉํ–ฅ์ผ ๊ฒฝ์šฐ main-axis ๊ธฐ์ค€์œผ๋กœ ๋™์ผํ•˜๊ฒŒ ์ž‘์šฉ

align-items: center;  //cross axis ์ค‘๊ฐ„์ •๋ ฌ
align-items: flex-start;  //cross axis ๊ธฐ์ค€ ์œ„์—์„œ ์•„๋ž˜
align-items: flex-end;  // cross axis ๊ธฐ์ค€ ์•„๋ž˜์—์„œ ์œ„๋กœ

coross axis ๋ฐฉํ–ฅ์œผ๋กœ ์ •๋ ฌํ•˜๊ณ  ์‹ถ์„ ๋•Œ

โœ๏ธalign-items/ align-contents ์ฐจ์ด

flex-warp: warp;

align-contents ์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด flex-warp์ด warp์ธ ์ƒํƒœ์—ฌ์•ผ ํ•จ
align-items๋Š” ํ•˜๋‚˜์˜ flex-axis ๊ธฐ์ค€.
align-contents ์ „์ฒด ํฐ flex-axis ๊ธฐ์ค€ ์ •๋ ฌ.

โœ๏ธorder

.red {order: 1;}
.yellow {order: 2;}
.blue {order: 3;}

flex ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ ๊ฐ ์š”์†Œ์— order ๊ฐ’์„ ์ฃผ๊ณ  ์ˆœ์„œ๋ฅผ ์›ํ•˜๋Š”๋Œ€๋กœ ๋ฐฐ์น˜ํ•  ์ˆ˜ ์žˆ์Œ

๐ŸŒท ๊ฒฐ๋ก 

์š”์†Œ๋ฅผ ๊ฐ์‚ฌ๊ณ  ์žˆ๋Š” ํƒœ๊ทธ์— flex ์‚ฌ์šฉ ์„ ์–ธ
flex์›ํ•˜๋Š” ๋ฐฉํ–ฅ ์„ค์ •ํ•˜๊ณ  ํ•œ ์ค„ ์ •๋ ฌ์ด๋ฉด nowarp, ์ƒ๊ด€์—†์œผ๋ฉด warp.

flex ์„ค์ • ๋ฐฉํ–ฅ(main-axis) ์ •๋ ฌ์‹œ justify-content
flex ์„ค์ • ๋ฐฉํ–ฅ๊ธฐ์ค€ ์ˆ˜์ง(cross-axis) ์ •๋ ฌ์‹œ align-items/ align-contents

flex ์‚ฌ์šฉ ์‹œ ๊ฐ ์š”์†Œ์— order ๊ฐ’์„ ์ฃผ์–ด ์›ํ•˜๋Š”๋Œ€๋กœ ์ˆœ์„œ๋ฐฐ์น˜ ๊ฐ€๋Šฅ

profile
Life is experience:)

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