๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
SITE/LAYOUT

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

by _ํ† ๋งคํ†  2022. 8. 5.
728x90

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

์ „์ฒด ์˜์—ญ์ด ๋“ค์–ด๊ฐ„ ๊ตฌ์กฐ๋กœ ์„ธ๋ถ€์ ์ธ ์š”์†Œ๋“ค์€ ๋ถ€๋ชจ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋งŒ๋“ค์–ด์„œ ๊ฐ€์šด๋ฐ ์˜์—ญ์œผ๋กœ ๋ ˆ์ด์•„์›ƒ์„ ์„ค์ •ํ•œ๋‹ค.
์ด๋ฒˆ ๋ ˆ์ด์•„์›ƒ์€ ์ข€ ๋” ์‹ฌํ™”๊ณผ์ •์œผ๋กœ ๋“ค์–ด๊ฐ„๋‹ค.

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

CSS ์Šคํƒ€์ผ์„ ํšจ์œจ์ ์œผ๋กœ ์ฃผ๊ธฐ ์œ„ํ•ด์„œ๋Š” html ๋งˆํฌ์—…์„ ๊น”๋”ํ•˜๊ฒŒ ์„ ์–ธํ•  ์ค„ ์•Œ์•„์•ผ ํ•œ๋‹ค. ๋•Œ๋ฌธ์— ๋จผ์ € ๋ ˆ์ด์•„์›ƒ ๋ถ„์„ ๋ฐ ์š”์†Œ์˜ ์ด๋ฆ„์„ ์ž˜ ์„ ์–ธํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•˜๋‹ค.

clearfix๋ฅผ ์ด์šฉํ•œ float์˜ ์˜์—ญ๊นจ์ง ๋ฐฉ์ง€
1. ๊นจ์ง€๋Š” ์˜์—ญ์— clear:both๋ฅผ ์„ค์ •ํ•œ๋‹ค.
2. ๋ถ€๋ชจ ๋ฐ•์Šค ์˜์—ญ์— overflowf: hidden์„ ์„ค์ •ํ•œ๋‹ค. - ์• ๋‹ˆ๋ฉ”์ด์…˜ ํšจ๊ณผ๊ฐ€ ์ ์šฉ๋˜์ง€ ์•Š๋Š”๋‹ค.
3. clearfix๋ฅผ ์„ค์ •ํ•œ๋‹ค. - ๊นจ์ง„ ๋ ˆ์ด์•„์›ƒ ์š”์†Œ์˜ ๋ถ€๋ชจ์š”์†Œ์—๊ฒŒ ํด๋ž˜์Šค๋กœ ์ด๋ฆ„์„ ์„ ์–ธํ•ด์ค€๋‹ค.
div class="container clearfix"


    * {
        margin: 0;
        padding: 0;
    }

    #wrap {}

    #header {
        width: 100%;
        height: 100px;
        background-color: #EEEBE9;
    }
    #header .container {
        height: 100px;
        background-color: #D7CCC8;
    }

    #nav {
        width: 100%;
        height: 100px;
        background-color: #A1887F;
    }
    #nav .container {
        height: 100px;

    }

    #main {
        width: 100%;
        height: 780px;
        background-color: #886F65;
    }

    #footer {
        width: 100%;
        height: 100px;
        background-color: #4E342E;
    }

    .container {
        width: 1200px;
        height: inherit;
        margin: 0 auto;
        background-color: rgba(0, 0, 0, 0.08);
    }

    .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;
    }

    /* clearfix  */
    .clearfix::before {
        zoom: 1;
    }

    .clearfix::before .clearfix::after {
        content: '';
        display: block;
        line-height: 0;
    }

    .clearfix::after {
        clear: both;
    }

    @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๋ฅผ ์ด์šฉํ•œ ๋ฐ˜์‘ํ˜• ๋ ˆ์ด์•„์›ƒ

๊ฐ ์š”์†Œ์—๊ฒŒ ๋ช…์นญ๊ณผ ์„ ํƒ์ž๋ฅผ ์ž˜ ์„ ์–ธํ•ด์ฃผ๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•˜๋‹ค. ํŠนํžˆ ์‹œ๋ฉ˜ํ‹ฑ ๋งˆํฌ์—…์— ๋Œ€ํ•œ ์ค‘์š”์„ฑ์„ ๋†“์น˜๋ฉด ์•ˆ๋˜๋ฉฐ ์˜๋ฏธ์žˆ๋Š” ๋งˆํฌ์—…์„ ํ•  ์ค„ ์•Œ์•„์•ผ ํ•œ๋‹ค.

 
* {
    margin: 0;
    padding: 0;
}

#wrap {}

#header {
    height: 100px;
    background-color: #EEEBE9;
}

#nav {
    height: 100px;
    background-color: #B9AAA5;
}

#main {
    height: 780px;
    background-color: #886F65;
}

#footer {
    height: 100px;
    background-color: #4E342E;
}

/* ์ปจํ…Œ์ด๋„ˆ */
.container {
    width: 1200px;
    height: inherit;
    background-color: rgba(0, 0, 0, 0.3);
    margin: 0 auto;
}

/* ๋ฉ”์ธ๋ฐ•์Šค ๊ตฌ์กฐ */
.contents {}

.contents .left {}

.contents .left .cont1 {
    width: 100%;
    height: 100px;
    background-color: #74574A;
}

/* contents ๊ตฌ์กฐ flex ์„ค์ • */
.contents .right {
    display: flex;
    flex-wrap: wrap;
}

.contents .right .cont2 {
    width: 100%;
    height: 200px;
    background-color: #684D43;
}

.contents .right .cont3 {
    width: 50%;
    height: 480px;
    background-color: #594139;
}

.contents .right .cont4 {
    width: 50%;
    height: 480px;
    background-color: #4A352F;
}

/* ๋ฏธ๋””์–ด์ฟผ๋ฆฌ ์„ค์ • */
@media (max-width: 1220px) {
    .container {
        width: 96%;
    }
    .contents {
        display: flex;
        flex-wrap: wrap;
    }
    
    .contents .left {
        width: 30%;
    }

    .contents .left .cont1 {
        width: 100%;
        height: 780px;
    }

    .contents .right {
        width: 70%;
    }

    .contents .right .cont2 {
        width: 100%;
        height: 390px;
    }

    .contents .right .cont3 {
        width: 50%;
        height: 390px;
    }

    .contents .right .cont4 {
        width: 50%;
        height: 390px;
    }

}

@media (max-width: 768px) {
    .container {
        width: 100%;
    }

    .contents .right .cont2 {
        width: 100%;
        height: 260px;
    }

    .contents .right .cont3 {
        width: 100%;
        height: 260px;
    }

    .contents .right .cont4 {
        width: 100%;
        height: 260px;
    }
}

@media (max-width: 480px) {
    .contents {
        display: flex;
        flex-wrap: wrap;
    }

    .contents .left {
        width: 100%;
        height: 150px;
    }

    .contents .left .cont1 {
        height: 150x;
    }

    .contents .right {
        width: 100%;
        height: 630px;
    }
    .contents .right .cont2 {
        height: 210px;
    }

    .contents .right .cont3 {
        height: 210px;
    }

    .contents .right .cont4 {
        height: 210px;
    }
}

gird๋ฅผ ์ด์šฉํ•œ ๋ฐ˜์‘ํ˜• ๋ ˆ์ด์•„์›ƒ

์„ธ๋ถ€์ ์ธ ์š”์†Œ๋“ค์ด ๋ณต์žกํ•˜๊ฒŒ ๋“ค์–ด๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ ํšจ์œจ์ ์ธ ๋งˆํฌ์—…๊ณผ ์‹œ๋ฉ˜ํ‹ฑ ๋งˆํฌ์—…์— ๋Œ€ํ•œ ์ค‘์š”๋„๊ฐ€ ๋†’์•„์ง„๋‹ค.
๊ฐ ์š”์†Œ์— ๋Œ€ํ•œ ๋ถ€๋ชจ์š”์†Œ์™€ ์ž์‹์š”์†Œ๋“ค์„ ํšจ์œจ์ ์œผ๋กœ ๋ถ„์„ํ•˜๊ณ  ๋‚˜๋ˆŒ ์ค„ ์•Œ์•„์•ผ ํ•œ๋‹ค.

 
* {
    margin: 0;
}

#wrap {}

#header {
    height: 100px;
    background-color: #EEEBE9;
}

#nav {
    height: 100px;
    background-color: #BCAAA4;
}

#main {
    height: 780px;
    background-color: #886F65;
}

#footer {
    height: 100px;
    background-color: #4E342E;
}

/* ์ปจํ…Œ๋ฆฌ๋„ˆ ์„ค์ • */

.container {
    width: 1200px;
    height: inherit;
    margin: 0 auto;
    background-color: rgba(0, 0, 0, 0.3);
}

/* contents ์„ค์ • */

.contents {
    display: grid;
    grid-template-areas:
        "cont1 cont1"
        "cont2 cont2"
        "cont3 cont4"
    ;
    grid-template-columns: 50% 50%;
    grid-template-rows: 100px 200px 480px;
}

.contents .cont1 {
    background-color: #74574A;
    grid-area: cont1;
}

.contents .cont2 {
    background-color: #684D43;
    grid-area: cont2;
}

.contents .cont3 {
    background-color: #594139;
    grid-area: cont3;
}

.contents .cont4 {
    background-color: #4A352F;
    grid-area: cont4;
}

/* ๋ฏธ๋””์–ด์ฟผ๋ฆฌ */

@media (max-width:1220px) {
    .container {
        width: 96%;
    }

    .contents {
    display: grid;
    grid-template-areas:
        "cont1 cont2 cont2"
        "cont1 cont3 cont4"
    ;
    /* grid-template-columns: 1fr 1fr 1fr;  3๋“ฑ๋ถ„ */
    grid-template-columns: repeat(3, 1fr);  /* 3๋“ฑ๋ถ„ */
    /* grid-template-columns: repeat(3, 33.3333%);  /* 3๋“ฑ๋ถ„ */
    /* grid-template-columns: 33.3333% 33.3333% 33.3333%;  3๋“ฑ๋ถ„ */
    /* grid-template-rows: 780px 200px 480px; */
    grid-template-rows: repeat(2, 1fr);
    }
}

@media (max-width:768px) {
    .contents {
    display: grid;
    grid-template-areas:
        "cont1 cont2"
        "cont1 cont3"
        "cont1 cont4"
    ;
    grid-template-columns: 30% 70%;
    grid-template-rows: repeat(3, 1fr);
    }
}   

@media (max-width:480px) {
    .contents {
    display: grid;
    grid-template-areas:
        "cont1"
        "cont2"
        "cont3"
        "cont4"
    ;
    grid-template-columns: 100%;
    grid-template-rows: 150px 210px 210px 210px;
    }
}

๊ฒฐ๊ณผ

728x90

'SITE > LAYOUT' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

๋ ˆ์ด์•„์›ƒ04  (4) 2022.07.29
๋ ˆ์ด์•„์›ƒ03  (4) 2022.07.29
๋ ˆ์ด์•„์›ƒ02  (4) 2022.07.29
๋ ˆ์ด์•„์›ƒ01  (5) 2022.07.27

๋Œ“๊ธ€


Lucky Charms Rainbow
js
html
css