728x90
λ°μν
π‘ μ€μ΅ ν¬μΈνΈ!
- μ€λμ display : grid λ₯Ό μ΄μ©νμ¬ μμμ λλλ λ°©λ²μ λ°°μ보μλλ°, μ²μ 보λ μμ±μ΄λΌ κ΅μ₯ν μ μ νλ€. μΌλ¨ μμ κ°μ μμμΌλ‘ λλλ λ°©λ²μ λ κ°μ§ λ°°μλ³΄κ³ , λ°μνμΌλ‘λ μ΄λ€ μμΌλ‘ λ§λλμ§ κ³΅λΆνλ€.
π PC νλ©΄
π€ 1λ²μ§Έ λ°©λ²
<div class="grid-container">
<div class="grid-nav"></div>
<div class="grid-sidebar"></div>
<div class="grid"></div>
</div>
.grid-container {
display: grid;
grid-template-columns: 100px 100px 100px 100px; /* fr μ μ 체 λλΉμ λν λΉμ¨μ μλ―Έ */
grid-template-rows: 100px 100px 100px;
/* grid-gap: 10px; */ /* grid-gap μ κ° grid μ¬μ΄μ κ°κ²©μ μλ―Έ */
}
.grid-container div {
border: 1px solid black;
}
.grid-nav {
grid-column: 1 / 5; /* display: grid μμλ€μλ§ μ¬μ©κ°λ₯ν μμ±, κ° μ«μλ μΈλ‘μ€ μλ²μ μλ―Έ */
grid-row: 1 / 2; /* display: grid μμλ€μλ§ μ¬μ©κ°λ₯ν μμ±, κ° μ«μλ κ°λ‘μ€ μλ²μ μλ―Έ */
}
.grid-sidebar {
grid-row: 2 / 4;
}
.grid {
grid-row: 2 / 4;
grid-column: 2 / 5;
}
π€ 2λ²μ§Έ λ°©λ²
<div class="grid-container2">
<div class="grid-nav2"></div>
<div class="grid-sidebar2"></div>
<div class="grid2"></div>
</div>
.grid-container2 {
display: grid;
grid-template-columns: 100px 100px 100px 100px;
grid-template-rows: 100px 100px 100px;
grid-template-areas:
"ν€λ ν€λ ν€λ ν€λ"
"μ¬μ΄λ 그리λ 그리λ 그리λ"
"μ¬μ΄λ 그리λ 그리λ 그리λ";
}
.grid-container2 div {
border: 1px solid black;
}
.grid-nav2 {
grid-area: ν€λ;
}
.grid-sidebar2 {
grid-area: μ¬μ΄λ;
}
.grid2 {
grid-area: 그리λ;
}
π λͺ¨λ°μΌ νλ©΄
- 1λ²μ§Έ λ°©λ²μμ media query λ₯Ό μΆκ°ν΄λ λ°μν λ μ΄μμμ λ§λ€ μ μμ§λ§ κ½€ λ²κ±°λ‘μ΄ λ°λ©΄, 2λ²μ§Έ λ°©λ²μ media query λ₯Ό μΆκ°λ‘ μ¬μ©νλ©΄ μ’ λ μ½κ² λ°μν λ μ΄μμλ λ§λ€ μ μλ€.
@media screen and (max-width: 768px) {
.grid-container2 {
grid-template-areas:
"ν€λ ν€λ ν€λ ν€λ"
"μ¬μ΄λ μ¬μ΄λ μ¬μ΄λ μ¬μ΄λ"
"그리λ 그리λ 그리λ 그리λ";
}
}
728x90
λ°μν
'[κ°λ°] Practice > HTML CSS' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[HTML/CSS] position: sticky νμ©νκΈ° (0) | 2022.03.02 |
---|---|
[HTML/CSS] grid-column, grid-row μΌλ‘ λ μ΄μμ λ§λ€κΈ° (0) | 2022.03.02 |
[HTML/CSS] transform & animation μΌλ‘ 맀λλ¬μ΄ μ λλ©μ΄μ λ§λ€κΈ° (0) | 2022.03.01 |
[HTML/CSS] HTML Video, Audio λ€λ£¨κΈ° (0) | 2022.03.01 |
[HTML/CSS] SCSS λ‘ row, col λ§λ€κΈ° (0) | 2022.03.01 |