728x90
#TYPE_2
앞서 배운 float/flex/gid 방식을 사용해 예제를 풀어봅시다. 색상과 치수는 아래 피그마를 참고해주세요 !
1-1. float을 사용해서 만들어주세요 !
* {
margin: 0;
padding: 0;
}
body {
background-color: #E8F5E9;
}
#wrap {
width: 1200px;
margin: 0 auto;
}
#header {
width: 100%;
height: 100px;
background-color: #C8E6C9;
}
#main {
width: 100%;
overflow: hidden;
}
#nav {
width: 100%;
height: 100px;
background-color: #A5D6A7;
}
#aside {
width: 25%;
height: 780px;
background-color: #81C784;
float: left;
}
#article {
width: 50%;
height: 780px;
background-color: #66BB6A;
float: left;
}
#section {
width: 25%;
height: 780px;
background-color: #4CAF50;
float: left;
}
#footer {
width: 100%;
height: 100px;
background-color: #43A047;
}
/* 미디어쿼리 */
@media (max-width: 1300px){
#wrap {
width: 96%;
}
}
@media (max-width: 768px){
#wrap {
width: 100%;
}
#aside {
width: 30%;
height: 630px;
}
#article {
width: 70%;
height: 630px;
}
#section {
width: 100%;
height: 150px;
}
}
@media (max-width: 480px){
#aside {
width: 100%;
height: 200px;
}
#article {
width: 100%;
height: 430px;
}
}
1-2. 결과를 확인해봅시다 !
See the Pen layout2_float by kkb75281 (@kkb75281) on CodePen.
2-1. flex를 사용해서 만들어주세요 !
* {
margin: 0;
padding: 0;
}
body {
background-color: #E8F5E9;
}
#wrap {
width: 1200px;
margin: 0 auto;
}
#header {
height: 100px;
background-color: #C8E6C9;
}
#nav {
height: 100px;
background-color: #A5D6A7;
}
#main {
display: flex;
}
#aside {
width: 25%;
height: 780px;
background-color: #81C784;
}
#article {
width: 50%;
height: 780px;
background-color: #66BB6A;
}
#section {
width: 25%;
height: 780px;
background-color: #4CAF50;
}
#footer {
height: 100px;
background-color: #43A047;
}
/* 미디어쿼리 */
@media (max-width: 1300px){
#wrap {
width: 96%;
}
}
@media (max-width: 768px){
#wrap {
width: 100%;
}
#main {
flex-wrap: wrap;
}
#aside {
width: 30%;
height: 630px;
}
#article {
width: 70%;
height: 630px;
}
#section {
width: 100%;
height: 150px;
}
}
@media (max-width: 480px){
#aside {
width: 100%;
height: 200px;
}
#article {
width: 100%;
height: 430px;
}
}
2-2. 결과를 확인해봅시다 !
See the Pen layout2_flex by kkb75281 (@kkb75281) on CodePen.
3-1. grid를 사용해서 만들어주세요 !
* {
margin: 0;
padding: 0;
}
body {
background-color: #E8F5E9;
}
#wrap {
width: 1200px;
margin: 0 auto;
}
#header {
height: 100px;
background-color: #C8E6C9;
}
#nav {
height: 100px;
background-color: #A5D6A7;
}
#main {
display: grid;
grid-template-columns: 25% 50% 25%;
grid-template-rows: 780px;
}
#aside {
background-color: #81C784;
}
#article {
background-color: #66BB6A;
}
#section {
background-color: #4CAF50;
}
#footer {
height: 100px;
background-color: #43A047;
}
/* 미디어쿼리 */
@media (max-width: 1300px){
#wrap {
width: 96%;
}
}
@media (max-width: 768px){
#wrap {
width: 100%;
}
#main {
grid-template-areas:
"aside article"
"section section"
;
grid-template-columns: 30% 70%;
grid-template-rows: 630px 150px;
}
#aside {
grid-area: aside;
}
#article {
grid-area: article;
}
#section {
grid-area: section;
}
}
@media (max-width: 480px){
#main {
grid-template-areas:
"aside"
"article"
"section"
;
grid-template-columns: 100%;
grid-template-rows: 200px 430px 150px;
}
}
3-2. 결과를 확인해봅시다 !
See the Pen layout2_grid by kkb75281 (@kkb75281) on CodePen.
'LAYOUT' 카테고리의 다른 글
layout | 레이아웃 예제5 (5) | 2022.08.02 |
---|---|
layout | 레이아웃 예제4 (5) | 2022.08.02 |
layout | 레이아웃 예제3 (4) | 2022.08.02 |
layout | 레이아웃 예제1 (5) | 2022.08.02 |
Layout | float, flex, grid 3가지 방법 (6) | 2022.07.25 |
댓글