๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋ ˆ์ด์•„์›ƒ

๋ ˆ์ด์•„์›ƒ 02

by Youcodein 2022. 7. 29.
728x90
๋ฐ˜์‘ํ˜•

๋ ˆ์ด์•„์›ƒ2

์‚ฌ์ดํŠธ๋ฅผ ๋งŒ๋“ค ๋•Œ ๊ธฐ๋ณธ์ด ๋˜๋Š” ๋ ˆ์ด์•„์›ƒ ์ž…๋‹ˆ๋‹ค.

float์„ ์ด์šฉํ•œ ๋ ˆ์ด์•„์›ƒ

<div>ํƒœ๊ทธ๋ฅผ float ์†์„ฑ ๋ฐ widh, height์†์„ฑ ๋“ฑ์„ ์ด์šฉํ•˜์—ฌ ๋ ˆ์ด์•„์›ƒ์„ ๋ฐฐ์น˜ํ•˜๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค.


    * {
        margin: 0;
        padding: 0;
    }
    #body {
        background-color: #E8F5E9;
    }
    #wrap {
        width: 1200px;
        margin: 0 auto;
    }
    #header {
        width: 100%;
        height: 100px;
        background-color: #C8E6C9;
    }
    #nav {
        width: 100%;
        height: 100px;
        background-color: #A5D6A7;
    }
    #main {
        width: 100%;
        overflow: hidden;
    }
    #aside {
        width: 30%;
        height: 780px;
        background-color: #81C784;
        float: left;
    }
    #section {
        width: 40%;
        height: 780px;
        background-color: #66BB6A;
        float: left;
    }
    #article {
        width: 30%;
        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;
        }
        #section {
            width: 70%;
            height: 630px;
        }
        #article {
            width: 100%;
            height: 150px;
        }
    }
    @media (max-width: 480px){
        #aside {
            width: 100%;
            height: 200px;
        }
        #section {
            width: 100%;
            height: 430px;
        }
    }

flex์„ ์ด์šฉํ•œ ๋ ˆ์ด์•„์›ƒ

header์™€ footer๋ฅผ ์ œ์™ธํ•œ ๋‚˜๋จธ์ง€ ์š”์†Œ๋“ค์„ container ํด๋ž˜์Šค๋กœ ๋ฌถ๊ณ  container์•ˆ์˜ ์š”์†Œ๋“ค์„ ๋ฐฐ์น˜ํ•˜๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค.

* {
        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: 30%;
        height: 780px;
        background-color: #81C784;
    }
    #section {
        width: 40%;
        height: 780px;
        background-color: #66BB6A;
    }
    #article {
        width: 30%;
        height: 780px;
        background-color: #4CAF50;
    }
    #footer {
        height: 100px;
        background-color: #43A047;
    }
    @media (max-width: 1300px){
        #wrap {
            width: 96%;
            margin: 0 auto;
        }
    }
    @media (max-width: 768px){
        #wrap {
            width: 100%;
        }
        #main{
            flex-wrap: wrap;
        }
        #aside {
            width: 30%;
            height: 630px;
        }
        #section {
            width: 70%;
            height: 630px;
        }
        #article {
            width: 100%;
            height: 150px;
        }
    }
    @media (max-width: 480px){
        #aside {
            width: 100%;
            height: 200px;
        }
        #section {
            width: 100%;
            height: 430px;
        }
    }

grid๋ฅผ ์ด์šฉํ•œ ๋ ˆ์ด์•„์›ƒ

grid ๋ ˆ์ด์•„์›ƒ์€ 1์ฐจ์› ์‹œ์Šคํ…œ์ธ ํ”Œ๋ ‰์Šค ๋ฐ•์Šค์™€๋Š” ๋‹ค๋ฅด๊ฒŒ ์—ด๊ณผ ํ–‰ ๋ชจ๋‘ ๋‹ค๋ฃฐ ์ˆ˜ ์žˆ๋Š” 2์ฐจ์› ์‹œ์Šคํ…œ์ด๋ฉฐ, CSS ๊ทœ์น™์— ๋”ฐ๋ผ ๋ถ€๋ชจ ์š”์†Œ(๊ทธ๋ฆฌ๋“œ ์ปจํ…Œ์ด๋„ˆ)์™€ ์ž์‹ ์š”์†Œ(๊ทธ๋ฆฌ๋“œ ์•„์ดํ…œ)๋กœ ๊ทธ๋ฆฌ๋“œ ๋ ˆ์ด์•„์›ƒ ์ž‘์—…์„ ํ•ฉ๋‹ˆ๋‹ค.

* {
        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: 30% 40% 30%;
        grid-template-rows: 780px;
    }
    #aside {
        background-color: #81C784;
    }
    #section {
        background-color: #66BB6A;
    }
    #article {
        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 section"
                "article article"
            ;
        grid-template-columns: 30% 70%;
        grid-template-rows: 680px 150px;
        }
        #aside {
            grid-area: aside;
        }
        #section {
            grid-area: section;
        }
        #article {
            grid-area: article;
        }
    }
    @media (max-width: 480px){
        #main {
            grid-template-areas: 
                "aside"
                "section"
                "article"
            ;
        grid-template-columns: 100%;
        grid-template-rows: 200px 430px 150px;
        }
    }
728x90
๋ฐ˜์‘ํ˜•

'๋ ˆ์ด์•„์›ƒ' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

๋ ˆ์ด์•„์›ƒ 05  (3) 2022.07.29
๋ ˆ์ด์•„์›ƒ 04  (3) 2022.07.29
๋ ˆ์ด์•„์›ƒ 03  (5) 2022.07.29
๋ ˆ์ด์•„์›ƒ 01  (5) 2022.07.29

๋Œ“๊ธ€