๐Ÿš€CSS - Flexbox

์ฉก์ฝ”๋”ยท2021๋…„ 7์›” 5์ผ
1
post-thumbnail
<div class="container">
	<div class="item item1">1</div>
	<div class="item item2">2</div>
	<div class="item item3">3</div>
	<div class="item item4">4</div>
	<div class="item item5">5</div>
</div>

<!--  div.container>div.item.item${$}*5 ๋ฅผ ํ•˜๋ฉด ๋˜‘๊ฐ™์ด ์ž‘์„ฑ๋จ-->
.container {
	background : beige;
	height : 100vh;
	display: flex;
	flex-direction : row;
	flex-wrap : wrap;
	/* flex-flow: row wrap; */
	/* justify-content : flex-end; */
}

.item {
	width:40px;
	height:40px;
	flex-grow:1;
}
.item1 {
	backgound : white
}
.item2 {
	backgound : black
}
.item3 {
	backgound : red
}
.item4 {
	backgound : blue
}
.item5 {
	backgound : yellow
}

1. Flexbox ์‹œ์ž‘

  • display : flex : flexbox ์ง€์ •

2. Flexbox ์†์„ฑ

  • flex-direction : row : ๊ฐ€๋กœ์ •๋ ฌ (1,2,3,4,5 )
  • flex-direction : row-reverse : ๊ฐ€๋กœ์ •๋ ฌ ๋ฐ˜๋Œ€ ( 5,4,3,2,1)
  • flex-direction : column : ์„ธ๋กœ์ •๋ ฌ
  • flex-direction : column-reverse : ์„ธ๋กœ์ •๋ ฌ ๋ฐ˜๋Œ€

  • flex-wrap : wrap : ํ™”๋ฉด์ด ์ž‘์•„์ง€๋ฉด ๋ฐ‘์ค„๋กœ ๋‚ด๋ ค๊ฐ
  • flex-wrap : wrap-reverse ํ™”๋ฉด์ด ์ž‘์•„์ง€๋ฉด ์œ„๋กœ ์˜ฌ๋ผ๊ฐ
  • flex-wrap : nowrap : ํ™”๋ฉด์ด ์ž‘์•„์ ธ๋„ ๋ฐ‘์ค„๋กœ ๋‚ด๋ ค๊ฐ€์ง€ ์•Š์Œ
  • flex-flow : column nowrap : ํ•œ์ค„๋กœ ์ž‘์„ฑ ๊ฐ€๋Šฅ

3. main axis ์†์„ฑ

  • justify-content : flex-start : ์•„์ดํ…œ์˜ ์œ„์น˜๋ฅผ ์‹œ์ž‘์ ์œผ๋กœ ๋ณ€๊ฒฝ
  • justify-content : flex-end : ์•„์ดํ…œ์˜ ์œ„์น˜๋ฅผ ๋์ ์œผ๋กœ ๋ณ€๊ฒฝ
  • justify-content : space-around : ์™ผ์ชฝ, ์˜ค๋ฅธ์ชฝ ์•ฝ๊ฐ„ ๋„์šฐ๊ณ  ๊ฐ„๊ฒฉ ์ •๋ ฌ
  • justify-content : space-evenly : ๋˜‘๊ฐ™์€ ๊ฐ„๊ฒฉ ์ •๋ ฌ
  • justify-content : space-between : ์™ผ์ชฝ,์˜ค๋ฅธ์ชฝ์€ ๋”ฑ ๋ถ™๊ฒŒ ๊ฐ„๊ฒฉ ์ •๋ ฌ

4. cross axis ์†์„ฑ

  • align-items : center : ์ค‘์‹ฌ์ถ•์˜ ๋ฐ˜๋Œ€์ถ•์œผ๋กœ ์ค‘๊ฐ„ ์ •๋ ฌ
  • align-items : baseline : ๋งŒ์•ฝ item1์ด ๋‹ค๋ฅธ ๊ฒƒ๊ณผ ํฌ๊ธฐ๊ฐ€ ๋‹ค๋ฅผ ๋•Œ ๋งž์ถฐ์คŒ
  • align-content : space-around : ์œ„์ชฝ, ์•„๋ž˜์ชฝ ์•ฝ๊ฐ„ ๋„์šฐ๊ณ  ๊ฐ„๊ฒฉ ์ •๋ ฌ
  • align-content : space-between : ์œ„์™€ ์•„๋ž˜๋Š” ๋”ฑ ๋ถ™์— ๊ฐ„๊ฒฉ ์ •๋ ฌ
  • align-content : space-evenly : ๋˜‘๊ฐ™์€ ๊ฐ„๊ฒฉ ์ •๋ ฌ
  • align-content : center : ๊ฐ€์šด๋ฐ๋กœ ๋ชจ์•„์คŒ

5. item ์†์„ฑ

  • flex-grow : 1 : ๋Š˜์–ด๋‚˜๋Š” ํฌ๊ธฐ ์กฐ์ ˆ (๊ธฐ๋ณธ๊ฐ’:0)
  • flex-shrink : 1 : ์ค„์–ด๋“œ๋Š” ํฌ๊ธฐ ์กฐ์ ˆ (๊ธฐ๋ณธ๊ฐ’:0)
  • flex-basis: 10% : ๋ฐ•์Šค ๋น„์œจ ์กฐ์ ˆ (๊ธฐ๋ณธ๊ฐ’:auto)
  • align-self : center : ํŠน์ • ์•„์ดํ…œ๋งŒ ์œ„์น˜๋ฅผ ์กฐ์ ˆ

6. ์ฐธ๊ณ  ํŽ˜์ด์ง€ List

Flexbox Froggy (Flexbox ์—ฐ์Šต๊ฒŒ์ž„ ํŽ˜์ด์ง€)
https://flexboxfroggy.com/#ko

Color Tool (์ƒ‰ ์กฐํ•ฉ ํ•ด์ฃผ๋Š” ํŽ˜์ด์ง€)
https://material.io/resources/color

profile
์ž˜ํ•ด๋ณด์ž

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

๊ด€๋ จ ์ฑ„์šฉ ์ •๋ณด