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

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

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

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

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

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

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

* {
    margin: 0;
    padding: 0;
}
#body {
    background-color: #FFF3E0;
}
#wrap {
    width: 1200px;
    margin: 0 auto;
}
#header {
    width: 100%;
    height: 100px;
    background-color: #FFE0B2;
}
#nav {
    width: 100%;
    height: 100px;
    background-color: #FFCC80;
}
#aside {
    width: 30%;
    height: 780px;
    background-color: #FFB74D;
    float: left;
}
#section {
    width: 70%;
    height: 780px;
    background-color: #FFA726;
    float: left;
}
#footer {
    width: 100%;
    height: 100px;
    background-color: #FF9800;
    clear: both;
}

/* ๋ฏธ๋””์–ด์ฟผ๋ฆฌ */
@media (max-width: 1300px){
    #wrap {
    width: 96%;
}
}
@media (max-width: 768px){
    #wrap {
    width: 100%;
}
}
@media (max-width: 480px){
    #aside {
    width: 100%;
    height: 300px;
}
#section {
    width: 100%;
    height: 480px;
}
}

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

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


    * {
        margin: 0;
        padding: 0;
    }
    #body {
        background-color: #FFF3E0;
    }
    #wrap {
        width: 1200px;
        margin: 0 auto;
        display: flex;
        flex-wrap: wrap;
    }
    #header {
        width: 100%;
        height: 100px;
        background-color: #FFE0B2;
    }
    #nav {
        width: 100%;
        height: 100px;
        background-color: #FFCC80;
    }
    #aside {
        width: 30%;
        height: 780px;
        background-color: #FFB74D;
    }
    #section {
        width: 70%;
        height: 780px;
        background-color: #FFA726;
    }
    #footer {
        width: 100%;
        height: 100px;
        background-color: #FF9800;
    }

    /* ๋ฏธ๋””์–ด์ฟผ๋ฆฌ */
    @media (max-width: 1300px){
        #wrap {
            width: 96%;
        }
    }
    @media (max-width: 768px){
        #wrap {
            width: 100%;
        }
    }
    @media (max-width: 480px){
        #aside {
        width: 100%;
        height: 300px;
    }
    #section {
        width: 100%;
        height: 480px;
    }
    }
>

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

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


    * {
        margin: 0;
        padding: 0;
    }
    #body {
        background-color: #FFF3E0;
    }
    #wrap {
        width: 1200px;
        margin: 0 auto;
        display: grid;
        grid-template-areas:
            "header header"
            "nav nav"
            "aside section"
            "footer footer";
        grid-template-columns: 30% 70%;
        grid-template-rows: 100px 100px 780px 100px;
    }
    #header {
        background-color: #FFE0B2;
        grid-area: header;
    }
    #nav {
        background-color: #FFCC80;
        grid-area: nav;
    }
    #aside {
        background-color: #FFB74D;
        grid-area: aside;
    }
    #section {
        background-color: #FFA726;
        grid-area: section;
    }
    #footer {
        background-color: #FF9800;
        grid-area: footer;
    }

    /* ๋ฏธ๋””์–ด์ฟผ๋ฆฌ */
    @media (max-width: 1300px){
        #wrap {
            width: 96%;
        }
    }
    @media (max-width: 768px){
        #wrap {
            width: 100%;
        }
    }
    @media (max-width: 480px){
        #wrap {
        grid-template-areas:
            "header"
            "nav"
            "aside"
            "section"
            "footer";
        grid-template-columns:100%;
        grid-template-rows: 100px 100px 300px 480px 100px;
    }
    }
728x90
๋ฐ˜์‘ํ˜•

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

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

๋Œ“๊ธ€