λ μ΄μμ 03
μ 체 μμμ΄ λ€μ΄κ° ꡬ쑰μ΄λ©° μ€μ μ¬μ΄νΈμμ μ΄λ° ꡬ쑰λ₯Ό λ§μ΄ μ¬μ©νκ³ μ»¨ν μ΄λλ₯Ό λ§λ€μ΄ κ°μ΄λ° μμμ μ€μ νλ€.
Floatμ μ΄μ©ν λ μ΄μμ
λ μ΄μμμ νμ μ‘μ λ <div> νκ·Έκ° μ¬μ©λλ©° ν΄λΉ νκ·Έλ
Block νμμ΄λ―λ‘ κ°λ‘λ‘ λλν μ λ ¬μ΄ λΆκ°λ₯νλ€.
μ΄λ λλν μ λ ¬ν΄μ£Όκ³ μ νλ μμμ CSS μμ±μ float: left;λ₯Ό
μ μ΄μ£Όλ©΄ λλν μ λ ¬μ΄ κ°λ₯νλ€.
λ¨, μ΄ μμ±μ μ°κ² λ κ²½μ°, μμ±μ μΌλ μλμ μμκ° λ³΄μ΄μ§ μκ²
λλ λ²κ·Έκ° λ°μνλλ° μ΄λ΄ λμλ 보μ΄μ§ μλ ν΄λΉ μμμ clear: both;λ₯Ό
μ μ΄λμΌλ©΄ ν΄κ²°λλ€.
λν clear: both; λμ 맨 μλμ clearfix λΆλΆμ μ μ΄λλ λ°©λ²λ μλ€.
* {
margin: 0;
padding: 0;
}
body {
background-color: #E1F5FE;
}
#wrap {
width: 1200px;
margin: 0 auto;
}
#header {
width: 1200px;
height: 100px;
background-color: #B3E5FC;
}
#nav {
width: 1200px;
height: 100px;
background-color: #81D4FA;
}
#main {
width: 1200px;
}
#aside {
width: 300px;
height: 780px;
background-color: #4FC3F7;
float: left;
}
#article1 {
width: 900px;
height: 260px;
background-color: #29B6F6;
float: left;
}
#article2 {
width: 900px;
height: 260px;
background-color: #03A9F4;
float: left;
}
#article3 {
width: 900px;
height: 260px;
background-color: #039BE5;
float: left;
}
#footer {
width: 1200px;
height: 100px;
background-color: #0288D1;
/* clear: both; */
}
/* clearfix */
.clearfix::before,
.clearfix::after {
content: '';
display: block;
line-height: 0;
}
.clearfix::after {
clear: both;
}
κ²°κ³Ό
Floatμ μ΄μ©ν λ μ΄μμ - λ°μν
wrap μμ±μ widthλ§μ 1200pxλ‘ κ³ μ μν¨ ν λλ¨Έμ§ μμ±μ width κ°μ
νΌμΌν
μ΄μ§λ‘ νμ°μν¨λ€.
λ―Έλμ΄ μΏΌλ¦¬μμ λ
ΈνΈλΆ μ μ©(max-width: 1300px), νλΈλ¦Ώ PC μ μ©(768px),
μ€λ§νΈν° μ μ©(480px) μ¬μ΄μ¦λ₯Ό λ§λ λ€.
* {
margin: 0;
padding: 0;
}
body {
background-color: #E1F5FE;
}
#wrap {
width: 1200px;
margin: 0 auto;
}
#header {
height: 100px;
background-color: #B3E5FC;
}
#nav {
height: 100px;
background-color: #81D4FA;
}
#main {
}
#aside {
width: 30%;
height: 780px;
background-color: #4FC3F7;
float: left;
}
#article1 {
width: 70%;
height: 260px;
background-color: #29B6F6;
float: left;
}
#article2 {
width: 70%;
height: 260px;
background-color: #03A9F4;
float: left;
}
#article3 {
width: 70%;
height: 260px;
background-color: #039BE5;
float: left;
}
#footer {
height: 100px;
background-color: #0288D1;
/* clear: both; */
}
/* clearfix */
.clearfix::before,
.clearfix::after {
content: '';
display: block;
line-height: 0;
}
.clearfix::after {
clear: both;
}
/* λ―Έλμ΄ μΏΌλ¦¬ */
@media (max-width : 1300px) {
#wrap {
width: 96%;
}
#article2 {
width: 35%;
height: 520px;
}
#article3 {
width: 35%;
height: 520px;
}
}
@media (max-width : 768px) {
#wrap {
width: 100%;
}
#article1 {
width: 70%;
height: 390px;
}
#article2 {
width: 70%;
height: 390px;
}
#article3 {
display: none;
}
}
@media (max-width : 480px) {
#aside {
width: 100%;
height: 100px;
}
#article1 {
width: 100%;
height: 430px;
}
#article2 {
width: 100%;
height: 150px;
}
}
κ²°κ³Ό
Flexλ₯Ό μ΄μ©ν λ μ΄μμ
κ°λ‘λ‘ μ λ ¬ν΄μ£Όκ³ μ νλ μμλ€μ΄ λ΄κΈ΄ λΆλͺ¨ μμ #mainμ display: flex;λ₯Ό μ μ΄μ€λλ€.
* {
margin: 0;
padding: 0;
}
body {
background-color: #E1F5FE;
}
#wrap {
width: 1200px;
margin: 0 auto;
}
#header {
height: 100px;
background-color: #B3E5FC;
}
#nav {
height: 100px;
background-color: #81D4FA;
}
#main {
display: flex;
flex-wrap: wrap;
flex-direction: column;
height: 780px;
}
#aside {
width: 30%;
height: 780px;
background-color: #4FC3F7;
}
#article1 {
width: 70%;
height: 260px;
background-color: #29B6F6;
}
#article2 {
width: 70%;
height: 260px;
background-color: #03A9F4;
}
#article3 {
width: 70%;
height: 260px;
background-color: #039BE5;
}
#footer {
height: 100px;
background-color: #0288D1;
}
κ²°κ³Ό
Flexλ₯Ό μ΄μ©ν λ μ΄μμ - λ°μν
* {
margin: 0;
padding: 0;
}
body {
background-color: #E1F5FE;
}
#wrap {
width: 1200px;
margin: 0 auto;
}
#header {
height: 100px;
background-color: #B3E5FC;
}
#nav {
height: 100px;
background-color: #81D4FA;
}
#main {
display: flex;
flex-wrap: wrap;
flex-direction: column;
height: 780px;
}
#aside {
width: 30%;
height: 780px;
background-color: #4FC3F7;
}
#article1 {
width: 70%;
height: 260px;
background-color: #29B6F6;
}
#article2-1 {
width: 100%;
height: 260px;
background-color: #03A9F4;
}
#article2-2 {
width: 100%;
height: 260px;
background-color: #039BE5;
}
#footer {
height: 100px;
background-color: #0288D1;
}
/* λ―Έλμ΄ μΏΌλ¦¬ */
@media (max-width : 1300px) {
#wrap {
width: 96%;
}
#article2 {
display: flex;
}
#article2-1 {
width: 50%;
height: 520px;
}
#article2-2 {
width: 50%;
height: 520px;
}
}
@media (max-width : 768px) {
#wrap {
width: 100%;
}
#article1 {
width: 100%;
height: 390px;
}
#article2-1 {
width: 100%;
height: 390px;
}
#article2-2 {
display: none;
}
}
@media (max-width : 480px) {
#aside {
width: 100%;
height: 200px;
}
#article1 {
height: 430px;
}
#article2-1 {
height: 150px;
}
}
κ²°κ³Ό
Gridλ₯Ό μ΄μ©ν λ μ΄μμ
tableμ²λΌ λ μ΄μμμ μ‘μ μ μλ λ°©λ² μ€ νλμ
λλ€.
display: grid;λ‘ Grid μ¬μ©μ νμ±ννλ©°, grid-template-columnsμμλ μμ λ°°μΉ κ°λ‘ κΈΈμ΄λ₯Ό,
grid-template-rowsμμλ μΈλ‘ κΈΈμ΄λ₯Ό μ§μ ν΄μ€λλ€.
* {
margin: 0;
padding: 0;
}
body {
background-color: #E1F5FE;
}
#wrap {
width: 1200px;
margin: 0 auto;
}
#header {
height: 100px;
background-color: #B3E5FC;
}
#nav {
height: 100px;
background-color: #81D4FA;
}
#main {
display: grid;
grid-template-areas:
"aside article1 article1"
"aside article2 article2"
"aside article3 article3";
grid-template-columns: 300px 900px;
grid-template-rows: 260px 260px 260px;
}
#aside {
background-color: #4FC3F7;
grid-area: aside;
}
#article1 {
grid-area: article1;
background-color: #29B6F6;
}
#article2 {
grid-area: article2;
background-color: #03A9F4;
}
#article3 {
grid-area: article3;
background-color: #039BE5;
}
#footer {
height: 100px;
background-color: #0288D1;
}
κ²°κ³Ό
Gridλ₯Ό μ΄μ©ν λ μ΄μμ - λ°μν
* {
margin: 0;
padding: 0;
}
body {
background-color: #E1F5FE;
}
#wrap {
width: 1200px;
margin: 0 auto;
}
#header {
height: 100px;
background-color: #B3E5FC;
}
#nav {
height: 100px;
background-color: #81D4FA;
}
#main {
display: grid;
grid-template-areas:
"aside article1 article1"
"aside article2 article2"
"aside article3 article3";
grid-template-columns: 300px 900px;
grid-template-rows: 260px 260px 260px;
}
#aside {
background-color: #4FC3F7;
grid-area: aside;
}
#article1 {
grid-area: article1;
background-color: #29B6F6;
}
#article2 {
grid-area: article2;
background-color: #03A9F4;
}
#article3 {
grid-area: article3;
background-color: #039BE5;
}
#footer {
height: 100px;
background-color: #0288D1;
}
/* λ―Έλμ΄ μΏΌλ¦¬ */
@media (max-width : 1300px) {
#wrap {
width: 96%;
}
#main {
display: grid;
grid-template-areas:
"aside article1 article1"
"aside article2 article3"
"aside article2 article3";
grid-template-columns: 30% 35% 35%;
grid-template-rows: 260px 520px;
}
}
@media (max-width : 768px) {
#wrap {
width: 100%;
}
#main {
display: grid;
grid-template-areas:
"aside article1"
"aside article2";
grid-template-columns: 30% 70%;
grid-template-rows: 390px 390px;
}
#article3 {
display: none;
}
}
@media (max-width : 480px) {
#main {
display: grid;
grid-template-areas:
"aside"
"article1"
"article2";
grid-template-columns: 100%;
grid-template-rows: 200px 430px 150px;
}
}
κ²°κ³Ό
'Layout' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[Layout] λ μ΄μμ 05 (7) | 2022.07.29 |
---|---|
[Layout] λ μ΄μμ 04 (7) | 2022.07.29 |
[Layout] λ μ΄μμ 02 (7) | 2022.07.29 |
[Layout] λ μ΄μμ 01 (7) | 2022.07.29 |
λκΈ