<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>
.container {
background : beige;
height : 100vh;
display: flex;
flex-direction : row;
flex-wrap : wrap;
}
.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