๐ฎ๐ธ ๊ฒ์์ผ๋ก ์์๋ณด๋ flex
๋ถ๋ชจ์
display โ flex๊ฐ ์์ด์ผํ๋ค.
ํ๋์ค๋ฅผ ์ฐ๋ฉด ๊ทธ ์์์ด ์ธ๋ผ์ธ์ด๋ผ๋ ๋ฐ๋ก ๊พธ๋ฐ์์์

flex-start: ์์๋ค์ ์ปจํ
์ด๋์ ์ผ์ชฝ์ผ๋ก ์ ๋ ฌํฉ๋๋ค.
flex-end: ์์๋ค์ ์ปจํ
์ด๋์ ์ค๋ฅธ์ชฝ์ผ๋ก ์ ๋ ฌํฉ๋๋ค.
center: ์์๋ค์ ์ปจํ
์ด๋์ ๊ฐ์ด๋ฐ๋ก ์ ๋ ฌํฉ๋๋ค.
space-between: ์์๋ค ์ฌ์ด์ ๋์ผํ ๊ฐ๊ฒฉ์ ๋ก๋๋ค. -> ๋ ์์ฃผ์
์๋์ ๋ถ์ธ์ํ์์ ์์๋ค ์ฌ์ด ๊ฐ๊ฒฉ ์ผ์
space-around: ์์๋ค ์ฃผ์์ ๋์ผํ ๊ฐ๊ฒฉ์ ๋ก๋๋ค.
์ธ๋ถ ๊ฐ๊ฒฉ์ด ์ผ์

space-evenly(FireFox Only): ์ฒซ๋ฒ์งธ๋ก ์ค๋ ์ ๋ ฌ ๋์ ์ ์ ๋๊ฐ ์ ์ธ์ ํ ์ ๋ ฌ ๋์ ์ฌ์ด์ ๊ฐ๊ฒฉ๊ณผ ๋ง์ง๋ง ์ ๋ ฌ ๋์ ์ดํ์ ๊ฐ๊ฒฉ์ด ๊ฐ๋๋ก ํญ๋ชฉ๋ถ์ฐ ๋ฉ๋๋ค.

flex-start: ์์๋ค์ ์ปจํ
์ด๋์ ๊ผญ๋๊ธฐ๋ก ์ ๋ ฌํฉ๋๋ค.
flex-end: ์์๋ค์ ์ปจํ
์ด๋์ ๋ฐ๋ฅ์ผ๋ก ์ ๋ ฌํฉ๋๋ค.
center: ์์๋ค์ ์ปจํ
์ด๋์ ์ธ๋ก์ ์์ ๊ฐ์ด๋ฐ๋ก ์ ๋ ฌํฉ๋๋ค.
baseline: ์์๋ค์ ์ปจํ
์ด๋์ ์์ ์์น์ ์ ๋ ฌํฉ๋๋ค.
stretch: ์์๋ค์ ์ปจํ
์ด๋์ ๋ง๋๋ก ๋๋ฆฝ๋๋ค.

row: ์์๋ค์ ํ
์คํธ์ ๋ฐฉํฅ๊ณผ ๋์ผํ๊ฒ ์ ๋ ฌํฉ๋๋ค.
row-reverse: ์์๋ค์ ํ
์คํธ์ ๋ฐ๋ ๋ฐฉํฅ์ผ๋ก ์ ๋ ฌํฉ๋๋ค.
์์์ ์ด ์ค๋ฅธ์ชฝ์ผ๋ก ์ด๋
column: ์์๋ค์ ์์์ ์๋๋ก ์ ๋ ฌํฉ๋๋ค.
column-reverse: ์์๋ค์ ์๋์์ ์๋ก ์ ๋ ฌํฉ๋๋ค.
-1 0 1๋ก ์ข์ฐ๋ก ์ด๋๊ฐ๋ฅ
-1์ ๋งจ์ผ์ชฝ 0์๊ธฐ๋ณธ 1์ ๋งจ์ค๋ฅธ์ชฝ
.์ ํ์ { order : }
.์ ํ์ { align-self: }
flex-start: ์์๋ค์ ์ปจํ
์ด๋์ ๊ผญ๋๊ธฐ๋ก ์ ๋ ฌํฉ๋๋ค.
flex-end: ์์๋ค์ ์ปจํ
์ด๋์ ๋ฐ๋ฅ์ผ๋ก ์ ๋ ฌํฉ๋๋ค.
center: ์์๋ค์ ์ปจํ
์ด๋์ ์ธ๋ก์ ์์ ๊ฐ์ด๋ฐ๋ก ์ ๋ ฌํฉ๋๋ค.
baseline: ์์๋ค์ ์ปจํ
์ด๋์ ์์ ์์น์ ์ ๋ ฌํฉ๋๋ค.
stretch: ์์๋ค์ ์ปจํ
์ด๋์ ๋ง๋๋ก ๋๋ฆฝ๋๋ค.

๋ด๊ฐ ์ง์ ํ ์์น์์ ์ข๊ฒ ๊ณ์ ๊พธ๊ฒจ์ ๋ฃ์ผ๋๊น ์จ์ (๋ค์์ค) ๋ฐ์ผ๋ก ๋จ๊ถ์ค์ผํจ
nowrap: ๋ชจ๋ ์์๋ค์ ํ ์ค์ ์ ๋ ฌํฉ๋๋ค.
wrap: ์์๋ค์ ์ฌ๋ฌ ์ค์ ๊ฑธ์ณ ์ ๋ ฌํฉ๋๋ค.
wrap-reverse: ์์๋ค์ ์ฌ๋ฌ ์ค์ ๊ฑธ์ณ ๋ฐ๋๋ก ์ ๋ ฌํฉ๋๋ค.
flex-direction๊ณผ flex-wrap ์์ฑ์ ํฉ์ณ๋์ ์ฝ์์์ฑ
flex-flow: column wrap;

์ฌ๋ฌ์ค์ ๊ต์ฐจ์ถ ์ ๋ ฌ๊ณผ ์ค ์ฌ์ด ๊ฐ๊ฒฉ ์ ์ด
flex-start: ์ฌ๋ฌ ์ค๋ค์ ์ปจํ
์ด๋์ ๊ผญ๋๊ธฐ์ ์ ๋ ฌํฉ๋๋ค.
flex-end: ์ฌ๋ฌ ์ค๋ค์ ์ปจํ
์ด๋์ ๋ฐ๋ฅ์ ์ ๋ ฌํฉ๋๋ค.
center: ์ฌ๋ฌ ์ค๋ค์ ์ธ๋ก์ ์์ ๊ฐ์ด๋ฐ์ ์ ๋ ฌํฉ๋๋ค.
space-between: ์ฌ๋ฌ ์ค๋ค ์ฌ์ด์ ๋์ผํ ๊ฐ๊ฒฉ์ ๋ก๋๋ค.
space-around: ์ฌ๋ฌ ์ค๋ค ์ฃผ์์ ๋์ผํ ๊ฐ๊ฒฉ์ ๋ก๋๋ค.
stretch: ์ฌ๋ฌ ์ค๋ค์ ์ปจํ
์ด๋์ ๋ง๋๋ก ๋๋ฆฝ๋๋ค.
display:flex๋ฅผ ๋ถ๋ชจ์์ ์ฃผ๊ณ , flex:1๋ก width์ ๊ฐ๊ฐ div๋ค์ด ๋ค์ด ๊ฐ ์ ์๊ฒ ํจ
๋ถ๋ชจ์์ gap์ ์ง์ ํด์ค์ ์ข์ฐ ๊ณต๋ฐฑ์ ์ค๋ค (์ฌ์ด ๊ณต๋ฐฑ)
margin: 0;padding: 0;

- ์๋ฐ ์ ํ์
.box2 div+div{ margin-left: 10px; }
- width๋ฅผ ์ค ์ ์๋ ๋๊ฐ์ง ๋ฐฉ๋ฒ
.box4 div{ 1. flex: 0 0 calc(50% - 5px); -> ์๋ผ๋์ง ์๊ณ width๋ง ์ฃผ๊ฒ ๋ค 2. width: calc(50% - 5px); height: 200px; background: #f00; }
flex: 1;
flex grow- ์๋ผ๋๋ค, ์ฆ๊ฐ๋ ๋์ ๋น์จflex shrink- ์์ถ๋์๋ ๋น์จ, ์ค์ด๋ค๋์ ๋น์จflex basis- ๊ฐ์ ํฉ์น๊ฑฐ, ์ค์ฌ์ถ๊ธฐ์ค ์๋ ๋์ด
-> ์์๋ค์ด 1๋1๋1๋ก ๋จน๊ฒ ๋ค๋๊ฑฐ- ex) flex : [grow], [shrink], [basis]

header{ position: fixed; top: 0;left: 0; width: 150px; background: #f00; height: 100vh; }100% - ๋ถ๋ชจ ํ๊ทธ์ 100%๋ฅผ ์ฌ์ฉํ๋ค๋ ์๋ฏธ
vh - ์ฌ์ฉ์์ ๋์ ๋ณด์ด๋ ์คํฌ๋ฆฐ ๋ฒ์์ ์ํฅ์ ๋ฐ๋๋ค.
- 1vh๋ 1/100 viewport-height
- ์ฆ ๋ทฐํฌํธ(์คํฌ๋ฆฐ) ๊ธฐ์ค 100๋ถ์ 1์ด๋ค. ๋ฐ๋ผ์ 100vh๋ ๋ทฐํฌํธ ์ ์ฒด ๋์ด๊ฐ ๋๋ค.
vw - ์ฌ์ฉ์์ ๋์ ๋ณด์ด๋ ์คํฌ๋ฆฐ ๋ฒ์์ ์ํฅ์ ๋ฐ๋๋ค.
- 1vw ์ญ์ 1/100 view-width
- ์ฆ ๋ทฐํฌํธ ๊ธฐ์ค 100๋ถ์ 1์ด๋ค. 100vw๋ ๋ทฐํฌํธ ์ ์ฒด ๋๋น์ ๊ฐ๋ค.
.box5 div+div{ flex: 0 0 100px; /* ๋๋ฆฌ์ง ์๊ณ with๋ง 100px๋ก ์ง์ */ background: #00f; margin-left: 10px; } .box6 div{ flex: 0 0 30%; /* ๋๋ฆฌ์ง ์๊ณ with๋ง 30%๋ก ์ง์ */ height: 200px; background: #f00; }

<h1 class="logo"> <a href=""> <span class="blind">ํ ์ค</span> </a> </h1>
์น ์ ๊ทผ์ฑ์ ๊ณ ๋ คํ์ฌ ์คํฌ๋ฆฐ ๋ฆฌ๋๊ธฐ๋ก ์ฝํ ์ ์๊ฒ ๋์์ค๋ค.
.blind { position: absolute; width: 1px; height: 1px; margin: -1px; /*์์ญ์์ ์ ์ธ์ํด*/ clip: rect(0 0 0 0); /*ํ๋ฏธ๊ฒฝ์ผ๋ก ํ๋ํ์ ๋ ๋ณด์ผ๊น๋ด .์ผ๋ก ์ ํ */ overflow: hidden; }๐ซ ์น ์ ๊ทผ์ฑ์ ๊ณ ๋ คํ์ง ์์ ์์ฑ๋ค / ์ฑ๋ฅ์ ํ
โ
display: none;-> ๋ฆฌ๋๊ธฐ๊ฐ ์ฝ์ง ์์
โopacity: 0;-> ๋ฆฌ๋๊ธฐ๊ฐ ์ฝ์ง ์์
โvisibility: hidden;-> ํ๊ตญ ๋ฆฌ๋๊ธฐ๋ง ์ฝ๋๋ค
โwidth:0, height:0-> ๊ฐ๋ก์ธ๋ก๊ฐ ์๊ธฐ๋์ ๋ชป์ฝ์
โabsolute: top:0,left:0
โabsolute: top:-9999px,left:-9999px
-> ํํ์ด์ง๊ฐ ๊ธ์ ์์์๋ถํฐ ์ฝ์ ๋ ์ฒ์ฒํ ๋ด๋ ค์ค๋ค๊ฐabsolute๋ฅผ ์ฝ์ผ๋ ค๊ณ ์ ์ผ์ชฝ ๊ฐ๋ค๊ฐ ๋ค์ ๋์์ค๊ธฐ ๋๋ฌธ์ ์ฑ๋ฅ์ด ์์ข์
โtext-indent: -9999px;->ํ ์คํธ๋ฅผ ๋งจ๋ค๋ ๋งจ์์ผ๋ก ๋ก๊ธฐ์ง๋ง ์ ์์
๐ clip์์ฑ์ ์ด์ฉํ๊ธฐ ์ํด์๋ position: absolute, fixed์ผ ๋ ๊ฐ๋ฅํ๋ฏ๋ก position์ ์ก์์ค ํ, width์ height๊ฐ 0์ธ ์ปจํ
์ธ ๋ ์ฝ์ ์ ์์ผ๋ฏ๋ก ์ต์ 1px์ฉ ์ฃผ๊ณ clip์ผ๋ก ์๋ผ์ margin: -1px, overflow: hidden์ ๊ฑธ์ด์ฃผ๋ฉด ๋๋ค.
-> blind๋ ๋์ค์ common(๊ณตํต)์ ๋ฃ์ด์ฃผ์!
<section class="sc-event"> <ul> <li> <a href=""> <img src="https://s.pstatic.net/static/www/mobile/edit/20220427/cropImg_728x360_92967740989307176.jpeg" alt=""> <p>Lorem ipsum dolor sit amet.</p> </a> </li> <ul> ....sc-event ul a{ display: block; padding: 10px; background: #f00; }aํ๊ทธ๋ ์ธ๋ผ์ธ์ด๊ธฐ ๋๋ฌธ์
display: block;์ ์ค์ผํ๋ค.

<link rel="stylesheet" href="./css/style.css">html์ css๋ฅผ ์ง์ ์ ์ผ๋ก ์ฐ๋๊ฒ ์๋ link๋ก ์ฐ๊ฒฐ์์ผ์ค๋ค.
<div class="bottom"> <ul class="left"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> </ul> <div class="right">right</div> </div>.bottom { display: flex; background: #fff; padding: 10px; } .bottom .left { display: flex; flex: 1; flex-wrap: wrap; justify-content: space-between; align-content: space-between; height: 200px; }
flex: 1;๋ฅผ ์ด์ฉํ์ฌ ๊ฐ๋ก ์ฌ์ด์ฆ๋ฅผ ์ก๋๋คjustify-content: space-between;์์๋ค ์ฌ์ด์ ๋์ผํ ๊ฐ๊ฒฉ์ฃผ๊ธฐalign-content: space-between;์ค์ฌ์ด์ ๋์ผํ ๊ฐ๊ฒฉ.bottom .left li { flex: 0 0 calc((100% - 20px) /3); background: #000; height: calc(50% - 5px); } .bottom .right { flex: 0 0 150px; background: #000; margin-left: 10px; }
- clac๋ฅผ ์ด์ฉํ์ฌ ์ฌ๋ฐฑ๊ฐ๋นผ๊ณ ์๋์ผ๋ก ๊ณ์ฐํ๊ธฐ

<section class="sc-box3"> <div class="wrap"> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> </ul> </div> </section>
.sc-box3 ul li:nth-child(1){flex: 0 0 calc(80% - 5px);} .sc-box3 ul li:nth-child(2){flex: 0 0 calc(20% - 5px);} .sc-box3 ul li:nth-child(3){flex: 0 0 calc(30% - 5px);} .sc-box3 ul li:nth-child(4){flex: 0 0 calc(70% - 5px);}๊ฐ๊ฐ ๊ฐ์์ ํ์๋ฅผ ์ด์ฉํ์ฌ ์ฌ๋ฐฑ๊ฐ์ ๋บ๊ฑธ ๊ณ์ฐํด์ค๋ค.
<section class="sc-box4"> <strong>๊ณต์ง์ฌํญ</strong> <div class="navi"> <a href="">์ด์ </a> <a href="">๋ค์</a> </div> </section>.sc-box4 .navi{display: flex;} .sc-box4 .navi a{ background: #fff; width: 50px;height: 50px; border: 1px solid #000; } .sc-box4 .navi a:nth-child(1){margin-right: -1px;}
๐ฌ ๋ด๊ฐ ์๊ฐํ ํด๊ฒฐ๋ฐฉ์
aํ๊ทธ์ displayํน์ flex๋ฅผ ์ฃผ์ง ์์ ๋ฐ์ํ๊ฑฐ ๊ฐ์ ๋ถ๋ชจ์ flex๋ฅผ ์คฌ๋ค.
ํด๊ฒฐ๋๋ฏ ๋ณด์์ง๋ง ๋๋ฒ์งธ ์ฌ์ง์ฒ๋ผ ๊ฒน์น๋๋ถ๋ถ์ด ๋๊บผ์์ง๋ค
-> ํด๊ฒฐ ๋ชปํจใ
border: 1px๊ฐ์ด ๋ค์ด๊ฐ ์๊ธฐ๋๋ฌธmargin-right: -1px;๋ฅผ ์ฃผ๋ฉด ๋๋ค!justify-content: space-between;๋ก ์ธํด ์ฌ๋ฐฑ์ด ์๊ฒผ์ง๋ง ๋ฐ์ ์ค์ ๋จ์ด์ง์ง ์์๋ค.
๐ฌ ๋ด๊ฐ ์๊ฐํ ํด๊ฒฐ๋ฐฉ์
1. ๊ฐ์์ ํ์๋ฅผ ์ด์ฉํด์ผํ๋ค.nth-child1,2,3...
-> css๊ฐ ๋๋ฌด ๊ธธ์ด์ง๋ค.
2. ๋๋ฒ์งธ ์ค์ ์๋์ ๋คํํ
ํด๋์ค ์ด๋ฆ์ ์ค๋ค.
-> ๋ฒ์กํ๋ค
flex๋ gap์ด ์๋ค!!
๋ถ๋ชจ์gap: 10px;์ ์ฃผ๋ฉด ์ข์ฐ ์์๋ ์ฌ๋ฐฑ์ด ์๊ธด๋ค.