728x90
#TYPE_5
앞서 배운 float/flex/gid 방식을 사용해 예제를 풀어봅시다. 색상과 치수는 아래 피그마를 참고해주세요 !
1-1. float을 사용해서 만들어주세요 !
* {
margin: 0;
padding: 0;
}
#wrap {
width: 100%;
}
#header {
width: 100%;
height: 100px;
background-color: #EEEBE9;
}
.header {
width: 100%;
height: 100px;
background-color: #D5CCC9;
}
#nav {
width: 100%;
height: 100px;
background-color: #B9AAA5;
}
.nav {
width: 100%;
height: 100px;
background-color: #9D8980;
}
#main {
width: 100%;
height: 780px;
background-color: #886F65;
}
#footer {
width: 100%;
height: 100px;
background-color: #4E342E;
}
.footer {
width: 100%;
height: 100px;
background-color: #3E2723;
}
.container {
width: 1200px;
height: inherit;
margin: 0 auto;
background-color: rgba(255,255,255,0.3);
}
.contents .cont1 {
width: 100%;
height: 100px;
background-color: #74574A;
}
.contents .cont2 {
width: 100%;
height: 200px;
background-color: #684D43;
}
.contents .cont3 {
width: 50%;
height: 480px;
background-color: #594139;
float: left;
}
.contents .cont4 {
width: 50%;
height: 480px;
background-color: #4A352F;
float: left;
}
.clearfix::before,
.clearfix::after {
content: '';
display: block;
line-height: 0;
}
.clearfix::after {
clear: both;
}
@media (max-width: 1220px) {
.container {
width: 96%;
}
.contents .cont1 {
width: 30%;
height: 780px;
float: left;
}
.contents .cont2 {
width: 70%;
height: 390px;
float: left;
}
.contents .cont3 {
width: 35%;
height: 390px;
}
.contents .cont4 {
width: 35%;
height: 390px;
}
}
@media (max-width: 768px) {
.container {
width: 100%;
}
.contents .cont1 {
width: 30%;
height: 780px;
}
.contents .cont2 {
width: 70%;
height: 260px;
}
.contents .cont3 {
width: 70%;
height: 260px;
}
.contents .cont4 {
width: 70%;
height: 260px;
}
}
@media (max-width: 480px) {
.contents .cont1 {
width: 100%;
height: 150px;
}
.contents .cont2 {
width: 100%;
height: 210px;
}
.contents .cont3 {
width: 100%;
height: 210px;
}
.contents .cont4 {
width: 100%;
height: 210px;
}
}
1-2. 결과를 확인해봅시다 !
See the Pen layout5_float by kkb75281 (@kkb75281) on CodePen.
2-1. flex를 사용해서 만들어주세요 !
* {
margin: 0;
padding: 0;
}
#wrap {}
#header {
height: 100px;
background-color: #EEEBE9;
}
#nav {
height: 100px;
background-color: #B9AAA5;
}
#main {
height: 780px;
background-color: #886F65;
}
#footer {
height: 100px;
background-color: #4E342E;
}
.container {
width: 1200px;
height: inherit;
margin: 0 auto;
background-color: rgba(0,0,0,0.3);
}
.contents {}
.contents .left {}
.contents .left .cont1 {
width: 100%;
height: 100px;
background-color: #74574A;
}
.contents .right {
display: flex;
flex-wrap: wrap;
}
.contents .right .cont2 {
width: 100%;
height: 200px;
background-color: #684D43;
}
.contents .right .cont3 {
width: 50%;
height: 480px;
background-color: #594139;
}
.contents .right .cont4 {
width: 50%;
height: 480px;
background-color: #4A352F;
}
/* 미디어쿼리 */
@media (max-width: 1220px) {
.container {
width: 96%;
}
.contents {
display: flex;
}
.contents .left {
width: 30%;
}
.contents .left .cont1 {
width: 100%;
height: 780px;
}
.contents .right {
width: 70%;
}
.contents .right .cont2 {
width: 100%;
height: 390px;
}
.contents .right .cont3 {
width: 50%;
height: 390px;
}
.contents .right .cont4 {
width: 50%;
height: 390px;
}
}
@media (max-width: 768px) {
.container {
width: 100%;
}
.contents .right .cont2 {
width: 100%;
height: 260px;
}
.contents .right .cont3 {
width: 100%;
height: 260px;
}
.contents .right .cont4 {
width: 100%;
height: 260px;
}
}
@media (max-width: 480px) {
.contents {
flex-wrap: wrap;
}
.contents .left {
width: 100%;
height: 150px;
}
.contents .left .cont1 {
height: 150px;
}
.contents .right {
width: 100%;
height: 630px;
}
.contents .right .cont2 {
height: 210px;
}
.contents .right .cont3 {
height: 210px;
}
.contents .right .cont4 {
height: 210px;
}
}
2-2. 결과를 확인해봅시다 !
See the Pen layout5_flex by kkb75281 (@kkb75281) on CodePen.
3-1. grid를 사용해서 만들어주세요 !
* {
margin: 0;
padding: 0;
}
#wrap {}
#header {
height: 100px;
background-color: #EEEBE9;
}
#nav {
height: 100px;
background-color: #B9AAA5;
}
#main {
height: 780px;
background-color: #886F65;
}
#footer {
height: 100px;
background-color: #4E342E;
}
.container {
width: 1200px;
height: inherit;
margin: 0 auto;
background-color: rgba(0,0,0,0.3);
}
.contents {
display: grid;
grid-template-areas:
"cont1 cont1"
"cont2 cont2"
"cont3 cont4"
;
grid-template-columns: 50% 50%;
grid-template-rows: 100px 200px 480px;
}
.contents .cont1 {
background-color: #74574A;
grid-area: cont1;
}
.contents .cont2 {
background-color: #684D43;
grid-area: cont2;
}
.contents .cont3 {
background-color: #594139;
grid-area: cont3;
}
.contents .cont4 {
background-color: #4A352F;
grid-area: cont4;
}
@media (max-width: 1220px) {
.container {
width: 96%;
}
.contents {
grid-template-areas:
"cont1 cont2 cont2"
"cont1 cont3 cont4"
;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(2, 1fr);
}
}
@media (max-width: 768px) {
.container {
width: 100%;
}
.contents {
grid-template-areas:
"cont1 cont2"
"cont1 cont3"
"cont1 cont4"
;
grid-template-columns: 30% 70%;
grid-template-rows: repeat(3, 1fr);
}
}
@media (max-width: 480px) {
.contents {
grid-template-areas:
"cont1"
"cont2"
"cont3"
"cont4"
;
grid-template-columns: 100%;
grid-template-rows: 150px 210px 210px 210px;
}
}
3-2. 결과를 확인해봅시다 !
See the Pen layout3_grid by kkb75281 (@kkb75281) on CodePen.
'LAYOUT' 카테고리의 다른 글
layout | 레이아웃 예제4 (5) | 2022.08.02 |
---|---|
layout | 레이아웃 예제3 (4) | 2022.08.02 |
layout | 레이아웃 예제2 (5) | 2022.08.02 |
layout | 레이아웃 예제1 (5) | 2022.08.02 |
Layout | float, flex, grid 3가지 방법 (6) | 2022.07.25 |
댓글