๋ ์ด์์03
๋ฉ์ธ์ ์ฌ์ด๋์ ์ํฐํด 3๊ฐ๊ฐ ๋ค์ด๊ฐ ๊ตฌ์กฐ
float์ ์ด์ฉํ ๋ ์ด์์ + ๋ฐ์ํ
float์ ๋ณธ๋ ๋ ์ด์์์ ์ฉ๋๊ฐ ์๋์์ผ๋ ๋ง๋
ํ ์์ฑ์ด ์์ด ์ฌ์ฉํ๊ฒ๋์๋ค. ๋ฅ๋ฅ ๋จ๋ ํํ๋ก float ์์ฑ์ด ์ ์ฉ์ด ์๋ blockbox๋ float๋ box ๋ฐ์ผ๋ก ๋ค์ด๊ฐ๊ฒ ๋๋ค.
๋๋ฌธ์ ๋ฐฐ์น์ด๋์ด ํ์ํ ์์์ float์ ์ด์ฉํ๋ฉด ์ธ๋ก๋ก๋ง ๋ฐฐ์น๋๋ ์์๋ฅผ ๊ฐ๋ก๋ก ๋๋ํ ๋ฐฐ์นํด์ค ์ ์๋ค.
์ฃผ ์ฌ์ฉ ์์ฑ
float: left; - ์์๋ฅผ ์๋ก ๋จ๊ฒ ํ์ฌ ์ผ์ชฝ์ผ๋ก ๋ฐฐ์นํด์ฃผ๋ ์์ฑ์ผ๋ก ์์ ์ด ๊ฐ ์ ์๋ ๊ฐ์ฅ ์ฒซ๋ฒ์งธ ์ผ์ชฝ์ ๋ฐฐ์น๊ฐ ๋๋ค.
clear: both; - float์ ํ ์์์๋๋ก ๋ค๋ฅธ ์์๊ฐ ์จ์ด๋ฒ๋ฆฌ๋ ๋ฒ๊ทธ๋ฅผ ์ก์์ฃผ๋ ์ญํ ์ ์์ฑ ๋ณดํต footer์ ๊ฐ์ ํ๋จ ์์์ ์คํ์ผ์ ์ ์ฉํ๋ค.
clearfix : float์ผ๋ก ์ธํ ์์ญ ๊นจ์ง์ ๋ฐฉ์งํ๊ธฐ ์ํด ์๊ธด ์์ฑ์ผ๋ก ๊นจ์ง ์์ญ์ ๋ํ ๋ถ๋ชจ์์์๊ฒ clearfix ์ ํ์๋ฅผ ์ ์ธํด์ค๋ค.
clearfix๋ฅผ ์ด์ฉํ ์์ญ๊นจ์ง ๋ฐฉ์ง
1. ๊นจ์ง๋ ์์ญ์ clear:both๋ฅผ ์ค์ ํ๋ค.
2. ๋ถ๋ชจ ๋ฐ์ค ์์ญ์ overflowf: hidden์ ์ค์ ํ๋ค. - ์ ๋๋ฉ์ด์
ํจ๊ณผ๊ฐ ์ ์ฉ๋์ง ์๋๋ค.
3. clearfix๋ฅผ ์ค์ ํ๋ค. - ๋ง๊ฐ์ง ๋ ์ด์์ ๋ถ๋ชจ๋ฐ์ค์ ํด๋์ค๋ก ์ด๋ฆ์ ์ค์ ํด์ค๋ค.
* {
margin: 0;
padding: 0;
}
body {
background-color: #E1F5FE;
}
#wrap {
width: 1200px;
margin: 0 auto;
}
#header {
width: 100%;
height: 100px;
background-color: #B3E5FC;
}
#nav {
width: 100%;
height: 100px;
background-color: #81D4FA;
}
#main {
width: 100%;
}
#aside {
width: 30%;
height: 780px;
background-color: #4FC3F7;
float: left;
}
#section {
width: 70%;
height: 260px;
background-color: #29B6F6;
float: left;
}
#article01 {
width: 70%;
height: 260px;
background-color: #03A9F4;
float: left;
}
#article02 {
width: 70%;
height: 260px;
background-color: #039BE5;
float: left;
}
#footer {
width: 100%;
height: 100px;
background-color: #0288D1;
}
/* clearfix */
.clearfix::after {
content: "";
display: block;
clear: both;
}
/* mediaqurey */
@media (max-width: 1220px){
#wrap {
width: 96%;
}
#article01 {
width: 35%;
height: 520px;
}
#article02 {
width: 35%;
height: 520px;
}
}
@media (max-width: 768px){
#wrap {
width: 100%;
}
#section {
width: 70%;
height: 390px;
}
#article01 {
width: 70%;
height: 390px;
}
#article02 {
display: none;
}
/* ๋ ์ด์์์ด ์ฌ๋ผ์ ธ์ผ ํ ๋ display: none์ ์ฌ์ฉํด์ฃผ์ด์ผ ํ๋ค. */
}
@media (max-width: 480px){
#aside {
width: 100%;
height: 200px;
}
#section {
width: 100%;
height: 430px;
}
#article01 {
width: 100%;
height: 150px;
}
}
flex์ ์ด์ฉํ ๋ ์ด์์ + ๋ฐ์ํ
๋ ์ด์์์ ๋ฐฐ์น๋ฅผ ์ํด ๋์ค๊ฒ ๋ ์์ฑ์ผ๋ก ๋ฐฐ์นํ๋ ๋ฐ ์์ด ๊ฐํธํ๋ค.
float๊ณผ ๋ฌ๋ฆฌ ๋ฐฐ์น๊ฐ ํ์ํ ๊ฐ ์์์ ์ ์ฉํ๋ ๊ฒ์ด ์๋๋ผ ๊ทธ ์์๋ค์ ํ๊ณ ์๋ ๋ถ๋ชจ ์์์๊ฒ ์คํ์ผ์ ์ ์ธํด์ฃผ์ด์ผ ํ๋ค.
๋๋ฌธ์ ๊ฐ ์น์
๊ณผ ๊ตฌ์กฐ๋ฅผ ์ ํ์
ํ์ฌ ๋ถ๋ชจ ์์ ๊ด๊ณ์ ๋ํ ๋งํฌ์
์ ์ ํด์ฃผ๋ ๊ฒ์ด ์ค์ํ๋ค.
์ฃผ ์ฌ์ฉ ์์ฑ
display: flex; - display๋ ์นํ์ด์ง์์ ๋ ์ด์์ ๋ฐ ์์๊ฐ ์ด๋ป๊ฒ ๋ณด์ด๋๊ฐ๋ฅผ ์ ์ธํด์ฃผ๋ ์์ฑ์ผ๋ก ์ฆ ํด๋น ์์๋ฅผ flex ์คํ์ผ๋ก ๋ณด์ด๊ฒ ํ๋ ์์ฑ
flex-wrap: wrap; - flex์์ฑ์ ํตํด ๋ฐฐ์นํ ์์๊ฐ ์ ์ ์ฉ๋๋๋ก ํด์ฃผ๋ ์์ฑ์ผ๋ก ์ ์ฉํ์ง ์์ ๊ฒฝ์ฐ ๋ฐฐ์น ์ ์ฉ์ด ๋์ง ์๋๋ค.
* {
margin: 0;
padding: 0;
}
body {
background-color: #E1F5FE;
}
#wrap {
width: 1200px;
margin: 0 auto;
}
#header {
width: 100%;
height: 100px;
background-color: #B3E5FC;
}
#nav {
width: 100%;
height: 100px;
background-color: #81D4FA;
}
#main {
display: flex;
flex-wrap: wrap;
flex-direction: column;
height: 780px;
}
#aside {
width: 30%;
height: 780px;
background-color: #4FC3F7;
}
#section {
width: 70%;
height: 260px;
background-color: #29B6F6;
}
#article1_01 {
width: 100%;
height: 260px;
background-color: #03A9F4;
}
#article1_02 {
width: 100%;
height: 260px;
background-color: #039BE5;
}
#footer {
height: 100px;
background-color: #0288D1;
}
/* mediaqurey */
@media (max-width: 1220px){
#wrap {
width: 96%;
}
#article1 {
display: flex;
}
#article1_01 {
width: 50%;
height: 520px;
}
#article1_02 {
width: 50%;
height: 520px;
}
/* ์ฌ์ด์ฆ ๋ณ ๋ ์ด์์์ด ๋ค๋ฅด๊ธฐ ๋๋ฌธ์ ํ๋ฒ ๋ ์ธ๋ถํ ์์ผ์ฃผ๋ ๊ฒ */
}
@media (max-width: 768px){
#wrap {
width: 100%;
}
#section {
height: 390px;
}
#article1 {
display: flex;
}
#article1_01 {
width: 100%;
height: 390px;
}
#article1_02 {
display: none;
}
}
@media (max-width: 480px){
#aside {
width: 100%;
height: 200px;
}
#section {
width: 100%;
height: 430px;
}
#article1_01 {
height: 150px;
}
}
grid์ ์ด์ฉํ ๋ ์ด์์ + ๋ฐ์ํ
flex์ ๋ง์ฐฌ๊ฐ์ง๋ก ๋ถ๋ชจ ์ปจํ
์ด๋์๊ฒ ์์ฑ์ ๋ถ์ฌํด์ค๋ค.
ํ์ง๋ง grid๋ flex์ ๋ค๋ฅด๊ฒ 2๊ฐ ์ถ์ ๋ชจ๋ ํ์ฉํ์ฌ ๊ฒฉ์(#) ์์ ์์ดํ
์ ๋ฐฐ์นํ๋ ๋ ์ด์์ ๋ฐฉ์์ด๋ค.
๋ณต์กํ ๊ตฌ์กฐ์ ์น์ ๊ตฌ์ฑํ๋ ค๋ฉด grid ๋ ์ด์์ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋ ๊ฒ์ด ํจ์จ์ ์ด๋ค.
์ฃผ ์ฌ์ฉ ์์ฑ
display: gird; - ๋ ์ด์์ ๋ฐ ์์๋ฅผ grid ์คํ์ผ๋ก ๋ณด์ด๊ฒ ํ๋ ์์ฑ
grid-template-areas - ๋ ์ด์์์ #๊ณผ ๊ฐ์ ๊ฒฉ์๋ก ๋๋์ด์ ๊ตฌ์กฐ๋ฅผ ๋๋์ด ์ฃผ๋ ์ญํ
grid-template-columns: ; - ๊ฒฉ์๋ก ๋๋ ์์์ ๊ฐ๋ก ๊ฐ์ ์ ํด์ฃผ๋ ์์ฑ
grid-template-rows: ; - ๊ฒฉ์๋ก ๋๋ ์์์ ์ธ๋ก ๊ฐ์ ์ ํด์ฃผ๋ ์์ฑ
grid-area: ; - ์์ ์ปจํ
์ด๋์๊ฒ ๋ถ๋ชจ์๊ฒ ๋ฃ์ ์คํ์ผ์ด ์ ์ฉ๋ ์ ์๋๋ก ์ด๋ฆ์ ๋ถ์ฌํด์ฃผ๋ ์์ฑ
* {
margin: 0;
padding: 0;
}
body {
background-color: #E1F5FE;
}
#wrap {
width: 1200px;
margin: 0 auto;
}
#header {
width: 100%;
height: 100px;
background-color: #B3E5FC;
}
#nav {
width: 100%;
height: 100px;
background-color: #81D4FA;
}
#main {
display: grid;
grid-template-areas:
"aside section"
"aside article01"
"aside article02"
;
grid-template-columns: 30% 70%;
grid-template-rows: 260px 260px 260px;
}
#aside {
background-color: #4FC3F7;
grid-area: aside;
}
#section {
grid-area: section;
background-color: #29B6F6;
}
#article01 {
grid-area: article01;
background-color: #03A9F4;
}
#article02 {
grid-area: article02;
background-color: #039BE5;
}
#footer {
height: 100px;
background-color: #0288D1;
}
/* mediaqurey */
@media (max-width: 1220px){
#wrap {
width: 96%;
}
#main {
grid-template-areas:
"aside section section"
"aside article01 article02"
"aside article01 article02"
;
grid-template-columns: 30% 35% 35%;
grid-template-rows: 260px 520px;
}
}
@media (max-width: 768px){
#wrap {
width: 100%;
}
#main {
grid-template-areas:
"aside section"
"aside article01"
;
grid-template-columns: 30% 70%;
grid-template-rows: 390px 390px;
}
#article02 {
display: none;
}
}
@media (max-width: 480px){
#main {
grid-template-areas:
"aside"
"section"
"article01"
;
grid-template-columns: 100%;
grid-template-rows: 200px 430px 150px;
}
}
'SITE > LAYOUT' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๋ ์ด์์05 (2) | 2022.08.05 |
---|---|
๋ ์ด์์04 (4) | 2022.07.29 |
๋ ์ด์์02 (4) | 2022.07.29 |
๋ ์ด์์01 (5) | 2022.07.27 |
๋๊ธ