728x90
๋ฐ์ํ
๋ ์ด์์3
์ด๋ฒ ๋ ์ด์์์ section์ด 4๊ฐ๋ก ๋๋์ด์ง ๋ ์ด์์์ ๋๋ค.
float์ ์ด์ฉํ ๋ ์ด์์
<div>ํ๊ทธ๋ฅผ float ์์ฑ ๋ฐ widh, height์์ฑ ๋ฑ์ ์ด์ฉํ์ฌ ๋ ์ด์์์ ๋ฐฐ์นํ๋ ๋ฐฉ์์ ๋๋ค.
/*
float์ผ๋ก ์ธํ ์์ญ๊นจ์ง ๋ฐฉ์ง๋ฒ
1. ๊นจ์ง๋ ์์ญ์ clear:both๋ฅผ ์ค์ ํ๋ค.
2. ๋ถ๋ชจ ๋ฐ์ค ์์ญ์ overflow: hidden์ ์ค์ ํ๋ค.
3. clearfix๋ฅผ ์ค์ ํ๋ค.
*/
.clearfix::before,
.clearfix::after{
content: '';
display: block;
line-height: 0;
}
.clearfix::after{
clear: both;
}
*{
margin: 0;
padding: 0;
}
#wrap {
width: 100%;
}
#header {
width: 100%;
height: 100px;
background-color: #EEEBE9;
}
#nav {
width: 100%;
height: 100px;
background-color: #B9AAA5;
}
#main {
width: 100%;
height: 780px;
background-color: #886F65;
}
#footer {
width: 100%;
height: 100px;
background-color: #4E342E;
}
.container {
width: 1200px;
height: inherit;
background-color: rgba(0,0,0,0.3);
overflow: hidden;
margin: 0 auto;
}
.header {
width: 1200px;
height: 100px;
background-color: #D5CCC9;
}
.nav {
width: 1200px;
height: 100px;
background-color: #9D8980;
}
.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;
}
.contents .footer {
width: 1200px;
height: 100px;
background-color: #3E2723;
}
@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;
}
}
flex์ ์ด์ฉํ ๋ ์ด์์
header์ footer๋ฅผ ์ ์ธํ ๋๋จธ์ง ์์๋ค์ container ํด๋์ค๋ก ๋ฌถ๊ณ container์์ ์์๋ค์ ๋ฐฐ์นํ๋ ๋ฐฉ์์ ๋๋ค.
* {
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;
float: left;
}
#article1 {
width: 70%;
height: 260px;
background-color: #29B6F6;
float: left;
}
#article2-1 {
width: 100%;
height: 260px;
background-color: #03A9F4;
float: left;
}
#article2-2 {
width: 100%;
height: 260px;
background-color: #039BE5;
float: left;
}
#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๋ฅผ ์ด์ฉํ ๋ ์ด์์
grid ๋ ์ด์์์ 1์ฐจ์ ์์คํ ์ธ ํ๋ ์ค ๋ฐ์ค์๋ ๋ค๋ฅด๊ฒ ์ด๊ณผ ํ ๋ชจ๋ ๋ค๋ฃฐ ์ ์๋ 2์ฐจ์ ์์คํ ์ด๋ฉฐ, CSS ๊ท์น์ ๋ฐ๋ผ ๋ถ๋ชจ ์์(๊ทธ๋ฆฌ๋ ์ปจํ ์ด๋)์ ์์ ์์(๊ทธ๋ฆฌ๋ ์์ดํ )๋ก ๊ทธ๋ฆฌ๋ ๋ ์ด์์ ์์ ์ ํฉ๋๋ค.
* {
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: 30% 70%;
grid-template-rows: 260px 260px 260px;
}
#aside {
background-color: #4FC3F7;
grid-area: aside;
}
#article1 {
background-color: #29B6F6;
grid-area: article1;
}
#article2 {
background-color: #03A9F4;
grid-area: article2;
}
#article3 {
background-color: #039BE5;
grid-area: article3;
}
#footer {
height: 100px;
background-color: #0288D1;
}
@media (max-width: 1300px){
#wrap {
width: 96%;
}
#main {
grid-template-areas:
"aside article1 article1"
"aside article2 article2"
"aside article3 article3";
grid-template-columns: 30% 35% 35%;
grid-template-rows: 260px 520px;
}
}
@media (max-width: 768px){
#wrap {
width: 100%;
}
#main {
grid-template-areas:
"aside article1 article1"
"aside article2 article2"
"aside article3 article3";
grid-template-columns: 30% 70%;
grid-template-rows: 390px 390px;
}
#article3 {
display: none;
}
}
@media (max-width: 480px){
#main {
grid-template-areas:
"aside"
"article1"
"article2";
grid-template-columns: 100%;
grid-template-rows: 200px 430px 150px;
}
}
728x90
๋ฐ์ํ
'๋ ์ด์์' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๋ ์ด์์ 04 (3) | 2022.07.29 |
---|---|
๋ ์ด์์ 03 (5) | 2022.07.29 |
๋ ์ด์์ 02 (5) | 2022.07.29 |
๋ ์ด์์ 01 (5) | 2022.07.29 |
๋๊ธ