πFlex box
νκ³Ό μ΄ ννλ‘ μμ μμλ₯Ό λ°°μΉνλ λ μ΄μμ μμ±. λΆλͺ¨ μμ λ΄λΆμ ν¬ν¨λ μμ μμλ€μ μΈλ‘, κ°λ‘ μ€μ¬λΆμ μ λ ¬νκ±°λ, μμ μμμ λλΉλ₯Ό λμΌνκ² μ€μ ν μ μλ€.
πμμ±
<body>
<div class="wrap">
<div class="parent">
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
</div>
</div>
</body>
html, body{
margin : 0;
padding: 0;
}
.parent{
width: 500px;
height: 600px;
background-color: pink;
display: flex;
flex-direction: column;
align-items: center;
}
.child{
width: 100px;
height: 100px;
border: 1px solid #000;
background-color: wheat;
}
flex-direction
μμ κ°μ΄ λΆλͺ¨ μμ λ΄μ μ¬λ¬ μμ μμκ° μμ λ, μ€νμΌμ `display: flex` λ₯Ό μμ±νλ©΄ flex boxλ‘ μμλ₯Ό λ€λ£° μ μλ€.
κΈ°λ³Έμ μΌλ‘ μμ μμκ° κ°λ‘λ‘ μ λ ¬λλ€.
`flex-direction` μ μ΄ λλ ν λ°©ν₯μΌλ‘ μ€μ ν μ μλ€. κΈ°λ³Έ κ°μ `flex-direction: row`μΌλ‘ μμ±κ°μ μμ±νμ§ μμΌλ©΄ μ΄ λ°©ν₯μΌλ‘ μ€μ λλ€.
.parent{
width: 500px;
height: 600px;
background-color: pink;
display: flex;
}
align-items
νμ¬ flex-boxμ λ°©ν₯μ΄ μ΄(row)λ‘ λμ΄μμΌλ―λ‘, `align-items: center` λ₯Ό μ μ©νλ©΄ μμ§ μ λ ¬ν μ μλ€.
.parent{
width: 500px;
height: 600px;
background-color: pink;
display: flex;
align-items: center;
}
νμ¬ λ°©ν₯μ΄ μ΄(row)μ΄λ―λ‘, `align-item : flex-end`λ₯Ό μ€μ νλ©΄ λΆλͺ¨ μμμ κ°μ₯ λλ¨μ λ°°μΉν μ μλ€.
κΈ°λ³Έκ°μ `flex-start` (μλ¨ κ³ μ )
.parent{
width: 500px;
height: 600px;
background-color: pink;
display: flex;
align-items: flex-end;
}
justify-content
νμ¬ flex-box λ°©ν₯μ΄ μ΄(row)λ‘ λμ΄μμΌλ―λ‘, `justify-content: center` λ₯Ό μ μ©νλ©΄ μν μ λ ¬ν μ μλ€.
.parent{
width: 500px;
height: 600px;
background-color: pink;
display: flex;
justify-content: center;
}
νμ¬ λ°©ν₯μ΄ μ΄(row)μ΄λ―λ‘, `justify : flex-end`λ₯Ό μ€μ νλ©΄ λΆλͺ¨ μμμ κ°μ₯ λλ¨μ λ°°μΉν μ μλ€.
κΈ°λ³Έκ°μ `flex-start` (μλ¨ κ³ μ )
.parent{
width: 500px;
height: 600px;
background-color: pink;
display: flex;
justify-content: flex-end;
}
νμ¬ λ°©ν₯μ΄ μ΄(row)μ΄λ―λ‘, `justify-content: space-around;`λ₯Ό μμ±νλ©΄ λΆλͺ¨ μμμ λ§μΆ° μ’μ° λ§μ§μ λμΌνκ² μ€μ νλ€.
.parent{
width: 500px;
height: 600px;
background-color: pink;
display: flex;
justify-content: space-around;
}
νμ¬ λ°©ν₯μ΄ μ΄(row)μ΄λ―λ‘, `justify-content: space-between;`λ₯Ό μμ±νλ©΄ μμ μ¬μ΄μ μ’μ° κ³΅κ°μ λμΌνκ² λ°°μΉνλ€. λ¨, 맨 μ²μ μμμ λ§μ§λ§ μμλ λ§μ§ μμ΄ λ± λΆμΈλ€.
.parent{
width: 500px;
height: 600px;
background-color: pink;
display: flex;
justify-content: space-between;
}
νμ¬ λ°©ν₯μ΄ μ΄(row)μ΄λ―λ‘, `justify-content: space-around;` λ₯Ό μμ±νλ©΄ μμ μ¬μ΄μ 곡κ°μ λμΌνκ² λ°°μΉνλ€. μ΄λ `justify-content: space-between;`μ λ¬λ¦¬ 맨 첫 μμμ λ§μ§λ§ μμμ μ’μ° μ¬λ°±λ λμΌν 곡κ°μΌλ‘ λ§μΆλ€.
.parent{
width: 500px;
height: 600px;
background-color: pink;
display: flex;
justify-content: space-around;
}
'HTML, CSS' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[HTML/CSS] μμ£Ό μ°λ νκ·Έ/μ€νμΌ (0) | 2024.10.17 |
---|