728x90
#TYPE_3
앞서 배운 float/flex/gid 방식을 사용해 예제를 풀어봅시다. 색상과 치수는 아래 피그마를 참고해주세요 !
1-1. float을 사용해서 만들어주세요 !
* {
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;
}
/* 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: 200px;
}
#article1 {
width: 100%;
height: 430px;
}
#article2 {
width: 100%;
height: 150px;
}
}
1-2. 결과를 확인해봅시다 !
See the Pen layout3_float by kkb75281 (@kkb75281) on CodePen.
2-1. 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 {
display: flex;
}
#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;
}
}
2-2. 결과를 확인해봅시다 !
See the Pen layout3_flex by kkb75281 (@kkb75281) on CodePen.
3-1. grid를 사용해서 만들어주세요 !
* {
margin: 0;
padding: 0;
}
body {
background-color: #E1F5FE;
}
#wrap {
width: 1200px;
margin: 0 auto;
display: grid;
grid-template-areas:
"header header"
"nav nav"
"aside article_1"
"aside article_2"
"aside section"
"footer footer"
;
grid-template-columns: 25% 75%;
grid-template-rows: 100px 100px 260px 260px 260px 100px;
}
#header {
grid-area: header;
background-color: #B3E5FC;
}
#nav {
grid-area: nav;
background-color: #81D4FA;
}
#aside {
grid-area: aside;
background-color: #4FC3F7;
}
#article_1 {
grid-area: article_1;
background-color: #29B6F6;
}
#article_2 {
grid-area: article_2;
background-color: #03A9F4;
}
#section {
grid-area: section;
background-color: #039BE5;
}
#footer {
grid-area: footer;
background-color: #0288D1;
}
@media (max-width: 1300px){
#wrap {
width: 96%;
grid-template-areas:
"header header header"
"nav nav nav"
"aside article_1 article_1"
"aside article_2 section"
"footer footer footer"
;
grid-template-columns: 25% 37.5% 37.5%;
grid-template-rows: 100px 100px 260px 520px 100px;
}
}
@media (max-width: 768px){
#wrap {
width: 100%;
grid-template-areas:
"header header"
"nav nav"
"aside article_1"
"aside article_2"
"footer footer"
;
grid-template-columns: 30% 70%;
grid-template-rows: 100px 100px 390px 390px 100px;
}
#section {
display: none;
}
}
@media (max-width: 480px){
#wrap {
grid-template-areas:
"header"
"nav"
"aside"
"article_1"
"article_2"
"footer"
;
grid-template-columns: 100%;
grid-template-rows: 100px 100px 200px 430px 150px 100px;
}
#section {
display: none;
}
}
3-2. 결과를 확인해봅시다 !
See the Pen layout3_grid by kkb75281 (@kkb75281) on CodePen.
'LAYOUT' 카테고리의 다른 글
layout | 레이아웃 예제5 (5) | 2022.08.02 |
---|---|
layout | 레이아웃 예제4 (5) | 2022.08.02 |
layout | 레이아웃 예제2 (5) | 2022.08.02 |
layout | 레이아웃 예제1 (5) | 2022.08.02 |
Layout | float, flex, grid 3가지 방법 (6) | 2022.07.25 |
댓글