๊ด€๋ฆฌ ๋ฉ”๋‰ด

JiYoung Dev ๐Ÿ–ฅ

CSS ๋ฐ•์Šค๋ชจ๋ธ (2023.04.27) ๋ณธ๋ฌธ

full stack/HTML, CSS

CSS ๋ฐ•์Šค๋ชจ๋ธ (2023.04.27)

Shinjio 2023. 4. 27. 18:31

๐ŸŽˆ ๋ฐ•์Šค ๋ชจ๋ธ(box model)

๋ชจ๋“  HTML ์š”์†Œ๋Š” ๋ฐ•์Šค(box) ๋ชจ์–‘์œผ๋กœ ๊ตฌ์„ฑ๋˜๋ฉฐ, ์ด๊ฒƒ์„ ๋ฐ•์Šค ๋ชจ๋ธ(box model)์ด๋ผ๊ณ  ๋ถ€๋ฆ„

→ ๋ฐ•์Šค๋Š” ๊ณต๊ฐ„ ํšจ์œจ์„ฑ์ด ์ข‹๊ธฐ ๋•Œ๋ฌธ

์š”์†Œ์˜ ๋ถ€ํ”ผ๊ฐ์„ ๊ฒฐ์ •ํ•˜๋Š” ๊ฐœ๋…

๋ฐ•์Šค๋ชจ๋ธ์€ HTML ์š”์†Œ๋ฅผ ํŒจ๋”ฉ(padding), ๋งˆ์ง„(margin), ๊ทธ๋ฆฌ๊ณ  ๋‚ด์šฉ(content)์œผ๋กœ ๊ตฌ๋ถ„

 

 

1. ๋‚ด์šฉ(content) 

ํ…์ŠคํŠธ๋‚˜ ์ด๋ฏธ์ง€๊ฐ€ ๋“ค์–ด์žˆ๋Š” ๋ฐ•์Šค์˜ ์‹ค์งˆ์ ์ธ ๋‚ด์šฉ ๋ถ€๋ถ„

 

2. ํŒจ๋”ฉ(padding)

๋‚ด์šฉ๊ณผ ํ…Œ๋‘๋ฆฌ ์‚ฌ์ด์˜ ๊ฐ„๊ฒฉ (๋ˆˆ์— ๋ณด์ด์ง€ ์•Š์Œ)

 

3. ํ…Œ๋‘๋ฆฌ(border)

๋‚ด์šฉ๊ณผ ํŒจ๋”ฉ ์ฃผ๋ณ€์„ ๊ฐ์‹ธ๋Š” ํ…Œ๋‘๋ฆฌ

 

4. ๋งˆ์ง„(margin)

ํ…Œ๋‘๋ฆฌ์™€ ์ด์›ƒํ•˜๋Š” ์š”์†Œ ์‚ฌ์ด์˜ ๊ฐ„๊ฒฉ (๋ˆˆ์— ๋ณด์ด์ง€ ์•Š์Œ)

 

๐ŸŽˆ ๋งˆ์ง„(margin)

ํ…Œ๋‘๋ฆฌ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์š”์†Œ์˜ ๋ฐ”๊นฅ ์—ฌ๋ฐฑ ์ง€์ •

background-color ์†์„ฑ์œผ๋กœ ์„ค์ •ํ•˜๋Š” ๋ฐฐ๊ฒฝ์ƒ‰์˜ ์˜ํ–ฅ์„ ๋ฐ›์ง€ ์•Š์Œ

 

 

โ–ผโ–ผโ–ผโ–ผ ๋งˆ์ง„(margin) ์‹ค์Šต โ–ผโ–ผโ–ผโ–ผ

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            /* body ํƒœ๊ทธ์˜ ๊ธฐ๋ณธ margin ๊ฐ’์€ 8px
                => default ๊ฐ’ */
            margin: 0px
        }

        #box{
            width : 100px;
            height : 100px;
            background-color: plum;

            /* margin : ๊ฒฝ๊ณ„์„ ์„ ๊ธฐ์ค€์œผ๋กœ ๋ฐ”๊นฅ ์—ฌ๋ฐฑ */

            /* margin: 50px; */
            /* margin-left: 10px;
            margin-top: 0px;
         */ 
        }

        .box{
            width : 100px;
            height : 100px;
        }

        #box1{
            background-color: red;
        }

        #box2{
            background-color: blue;
            margin-left : 100px;
        }

        #box3{
            background-color: green;
            margin-left: 200px;
        }

        #box4{
            background-color: gray;
            margin-left: 300px;
        }

    </style>
</head>
<body>
    <!-- id#box ๋‹จ์ถ• ๋ช…๋ น์–ด -->
    <div id="box">Content</div>

    <h2>์‹ค์Šต๋ฌธ์ œ</h2>
    <div class="box" id="box1"></div>
    <div class="box" id="box2"></div>
    <div class="box" id="box3"></div>
    <div class="box"id="box4"></div>
</body>
</html>

 

๐ŸŽˆ ํŒจ๋”ฉ(padding)

ํ…Œ๋‘๋ฆฌ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์š”์†Œ์˜ ์•ˆ์ชฝ ์—ฌ๋ฐฑ ์ง€์ •

background-color ์†์„ฑ์œผ๋กœ ์„ค์ •ํ•˜๋Š” ๋ฐฐ๊ฒฝ์ƒ‰์˜ ์˜ํ–ฅ์„ ํ•จ๊ป˜ ๋ฐ›์Œ

 

โ–ผโ–ผโ–ผโ–ผ ํŒจ๋”ฉ(padding) ์‹ค์Šต โ–ผโ–ผโ–ผโ–ผ

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            width: 100px;
            height: 100px;
            background-color: aquamarine;

            /* padding :
            ํ…Œ๋‘๋ฆฌ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์š”์†Œ์˜ ์•ˆ์ชฝ ์—ฌ๋ฐฑ์„ ์ง€์ •ํ•˜๋Š” ์†์„ฑ
            ํ…Œ๋‘๋ฆฌ์™€ ๋‚ด์šฉ ์‚ฌ์ด์— ์žˆ๋Š” ์—ฌ๋ฐฑ์ด๊ธฐ ๋•Œ๋ฌธ์— ์š”์†Œ์˜ ์„ฑ์งˆ์„ ๋”ฐ๋ฅธ๋‹ค. 
            ์•ˆ์ชฝ์— ์žˆ๋Š” ๋‚˜์˜ ๋‚ด์šฉ์„ ๋” ์•ˆ์ชฝ์œผ๋กœ ๋„ฃ๊ณ  ์‹ถ์„ ๋•Œ ์‚ฌ์šฉ! */
            padding: 30px;
        }

        .box{
            width : 100px;
            height : 100px;
        }

        #box1{
            background-color: pink;
        }

        #box2{
            background-color: skyblue;
            padding-left : 100px;
        }

        #box3{
            background-color: rgb(99, 241, 142);
            padding-left: 200px;
        }

        #box4{
            background-color: rgb(241, 241, 177);
            padding-left: 300px;
        }
        
    </style>
</head>
<body>
    <div id="box">Content</div>

    <h2>์‹ค์Šต๋ฌธ์ œ</h2>
    <div class="box" id="box1">BOX</div>
    <div class="box" id="box2">BOX</div>
    <div class="box" id="box3">BOX</div>
    <div class="box" id="box4">BOX</div>
</body>
</html>

 

๐ŸŽˆ box-sizing 

์š”์†Œ์˜ ํฌ๊ธฐ๋ฅผ ํ™”๋ฉด์— ํ‘œ์‹œํ•˜๋Š” ๋ฐฉ์‹

 

๋‚ด๊ฐ€ padding, border๊ฐ’์„ ์ฃผ๊ณ ์‹ถ์€๋ฐ ๋‚˜์˜ ๋„ํ˜•์ด ์ปค์ง€๋Š”๊ฒŒ ์‹ซ๋‹ค? 
→ box-sizing : border-box ์‚ฌ์šฉ! 

๋‚ด๊ฐ€ padding, border ๊ฐ’์„ ์ฃผ๋Š” ์กฑ์กฑ ๋„ํ˜•์— ๋ณ€ํ™”๊ฐ€ ์žˆ์—ˆ์œผ๋ฉด ์ข‹๊ฒ ๋‹ค?
→ box-sizing : content-box (๋””ํดํŠธ)

 

 

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            /* ๋‚ด๊ฐ€ ์„ค์ •ํ•œ ๋„ˆ๋น„ (content) */
            width: 500px;

            /* ์•ˆ์ชฝ ์—ฌ๋ฐฑ (padding) */
            padding: 20px;

            /* ๊ฒฝ๊ณ„์„  (border) */
            border: 20px solid gray;

        }

        /* Box-Sizing ์š”์†Œ์˜ ํฌ๊ธฐ๋ฅผ ํ™”๋ฉด์— ํ‘œ์‹œํ•˜๋Š” ๋ฐฉ์‹ */

        /* (1) content-box
        ๋‚ด๊ฐ€ ์„ค์ •ํ•œ ๋„ˆ๋น„ ๊ฐ’ = ์ปจํ…์ธ ์˜ ๋„ˆ๋น„ ๊ฐ’
        box-sizing์˜ ๊ธฐ๋ณธ ๊ฐ’
        ์ปจํ…์ธ  ์˜์—ญ๋งŒ์„ ํฌ๊ธฐ๋กœ ์‚ผ๋Š” ์†์„ฑ์œผ๋กœ 
        ํŒจ๋”ฉ, ๋ณด๋” ๊ฐ’์ด ์ถ”๊ฐ€๋กœ ๋“ค์–ด๊ฐ€๋ฉด ๋“ค์–ด๊ฐ„ ๋งŒํผ
        ์ „์ฒด ๋„ํ˜•์˜ ํฌ๊ธฐ๊ฐ€ ์ปค์ง„๋‹ค. */

        /* (2) border-box 
        ๋‚ด๊ฐ€ ์„ค์ •ํ•œ ๋„ˆ๋น„ = border๊นŒ์ง€์˜ ๋„ˆ๋น„
        content + padding + border = ๋‚ด๊ฐ€ ์„ค์ •ํ•œ ๋„ˆ๋น„
        padding, border๋ฅผ ๋„ฃ์–ด๋„ ์ „์ฒด ํฌ๊ธฐ๋Š” ์ปค์ง€์ง€ ์•Š์œผ๋ฉฐ
        content์˜ ํฌ๊ธฐ๋งŒ ์ž‘์•„์ง„๋‹ค. */

        .bb{
            box-sizing: border-box;
        }

    </style>
</head>
<body>
    <div class="cb">
        <p>content-box</p>
    </div>
    <div class="bb">
        <p>border-box</p>
    </div>
</body>
</html>

 

์‹ ํ˜ธ๋“ฑ ๋งŒ๋“ค๊ธฐ ์‹ค์Šต โ–ผโ–ผโ–ผโ–ผ

 

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #bg{
            width: 120px;
            height: 360px;
            background-color: black;
            border-radius: 20px;
            padding: 20px 10px;
            box-sizing: border-box;
        }

        .light{
            width: 100px;
            height: 100px;
            border-radius: 50px;
        }

        #red{
            background-color: red;
        }

        #yellow{
            background-color: yellow;
            margin: 10px 0 10px 0;
        }

        #green{
            background-color: green;
        }

    </style>
</head>
<body>
    <!-- 1. ๊ฒ€์ •์ƒ‰ div
    - width : 120px, height : 360px
    - ๋ฐฐ๊ฒฝ์ƒ‰ : black -->
    <!-- 2. ์‚ผ์ƒ‰๋“ฑ div (red, yellow, green)
    - width : 100px, height : 100px -->
    <!-- tip!!!
    - margin์—๋Š” ์ค‘์ฒฉํ˜„์ƒ์ด ์ผ์–ด๋‚œ๋‹ค!
    - padding์„ ์ด์šฉํ•˜๋ฉด ํฌ๊ธฐ๊ฐ€ ์ปค์ง. ๊ทธ๋Ÿฌ๋‚˜ ํฌ๊ธฐ๋Š” ์†๋Œ€์ง€ ๋ง๊ฒƒ ! (box-sizing : border box ํ™œ์šฉ)
    - ๊ฒ€์ •์ƒ‰ div ์•ˆ์—๋‹ค๊ฐ€ ์ž์‹ ์š”์†Œ๋กœ ์‚ผ์ƒ‰ div๋ฅผ ๋„ฃ์–ด์•ผ ํ•จ -->
    
    <!-- ๊ฒ€์ •์ƒ‰ div : bg -->
    <div id="bg">
        <!-- ์‚ผ์ƒ‰๋“ฑ div : light -->
        <div class="light" id="red"></div>
        <div class="light" id="yellow"></div>
        <div class="light" id="green"></div>
    </div>

</body>
</html>

 

๐ŸŽˆ border

์š”์†Œ์˜ ํ…Œ๋‘๋ฆฌ

border : ์„ ๋‘๊ป˜ ์„ ์ข…๋ฅ˜ ์„ ์ƒ‰๊น”;

 

 

'

 

์ค‘์š”ํ•œ ๊ฒƒ์€ border-radius

 

 

4๋ฐฉํ–ฅ ๋ชจ๋‘ ์ ์šฉ >> border-radius : 50px(์ •์‚ฌ๊ฐํ˜• ๊ธธ์ด์˜ 50%)

 

border ์‹ค์Šต โ–ผโ–ผโ–ผโ–ผ

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

        /* border-radius : ๊ฒฝ๊ณ„์„ ์„ ๋‘ฅ๊ธ€๊ฒŒ ๋งŒ๋“ค์–ด์ฃผ๋Š” ์†์„ฑ
        border - ์œ„/์•„๋ž˜ - ์ขŒ/์šฐ - radius
        ๋งŒ์•ฝ ๋„ค ๋ฐฉํ–ฅ ๋ชจ๋‘ ๋‘ฅ๊ธ€๊ฒŒ ๋งŒ๋“ค์–ด์ฃผ๊ณ  ์‹ถ๋‹ค๋ฉด?
        border-radius
         */

        body{
            /* body ํƒœ๊ทธ์˜ ๊ธฐ๋ณธ margin ๊ฐ’์€ 8px
                => default ๊ฐ’ */
            margin: 0px
        }

        #box{
            width : 100px;
            height : 100px;
            background-color: plum;

            /* margin : ๊ฒฝ๊ณ„์„ ์„ ๊ธฐ์ค€์œผ๋กœ ๋ฐ”๊นฅ ์—ฌ๋ฐฑ */

            /* margin: 50px; */
            /* margin-left: 10px;
            margin-top: 0px;
         */ 

            /* border-radius */
            /* ์˜ค๋ฅธ์ชฝ ์œ„์ชฝ์„ ๋‘ฅ๊ธ€๊ฒŒ? */
            border-top-right-radius: 20px;
            /* ์„ธ์‹ฌํ•˜๊ฒŒ ๊นŽ๊ณ  ์‹ถ๋‹ค๋ฉด -> px,  ๊ธธ๊ฒŒ ๊นŽ๊ณ  ์‹ถ์œผ๋ฉด -> % ์‚ฌ์šฉ */

            /* ์™ผ์ชฝ ์•„๋ž˜๋ฅผ ๋‘ฅ๊ธ€๊ฒŒ? */
            border-bottom-left-radius: 60px;

            /* ๋ชจ๋“  ๋ฐฉํ–ฅ์„ ๋‘ฅ๊ธ€๊ฒŒ? */
            border-radius: 50px;
        }

        .box{
            width : 100px;
            height : 100px;
            border-top-left-radius: 50px;
            border-bottom-right-radius: 0px;
        }

        #box1{
            /* width: 100px;
            height : 100px; */
            background-color: red;
        }

        #box2{
            /* width: 100px;
            height : 100px; */
            background-color: blue;
            margin-left : 100px;
        }

        #box3{
            /* width: 100px;
            height : 100px; */
            background-color: green;
            margin-left: 200px;
        }

        #box4{
            /* width: 100px;
            height : 100px; */
            background-color: gray;
            margin-left: 300px;
        }

    </style>
</head>
<body>
    <!-- id#box ๋‹จ์ถ• ๋ช…๋ น์–ด -->
    <div id="box">Content</div>

    <h2>์‹ค์Šต๋ฌธ์ œ</h2>
    <div class="box" id="box1"></div>
    <div class="box" id="box2"></div>
    <div class="box" id="box3"></div>
    <div class="box"id="box4"></div>
</body>
</html>

 

โ€ป ์ฃผ์˜ํ•  ์ 

margin ์ค‘์ฒฉ >> margin ์ค‘์ฒฉ์ด ์ผ์–ด๋‚  ๋•Œ๋Š” padding์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค

 

 

๐ŸŽˆ disply : flex โœจโœจโœจ

flex box๋ผ๊ณ ๋„ ๋ถˆ๋ฆฌ๋ฉฐ, ๋ ˆ์ด์•„์›ƒ์„ ๋ฐฐ์น˜ํ•˜๊ธฐ ์œ„ํ•ด ๋‚˜์˜จ ๊ธฐ๋Šฅ 

- container(๋ฐ”๊นฅ ๋ฐ•์Šค) ์™€ item(๋‚ด๋ถ€ ๋ฐ•์Šค)์œผ๋กœ ๊ตฌ์„ฑ 

- container์—์„œ display:flex ์„ ์–ธ ํ›„ ๊ธฐํƒ€ ํ–‰์œ„ ์ฝ”๋“œ ์ž‘์„ฑ

- container์— ์ž‘์„ฑํ•ด์•ผ ํ•˜๋Š” ์š”์†Œ 

  1. ๋‚ด๋ถ€์— ๋“ค์–ด๊ฐ€๋Š” item๋“ค์„ ์–ด๋–ป๊ฒŒ ์ •๋ ฌ์‹œํ‚ฌ ๊ฒƒ์ธ๊ฐ€ (๋ฐฐ์น˜๋ฐฉํ–ฅ) >>>> flex-direction 

      item๋“ค์˜ ๊ฐ€๋กœ์ •๋ ฌ ํ˜น์€ ์„ธ๋กœ์ •๋ ฌ

  2. ๋ฉ”์ธ์ถ•์„ ๊ธฐ์ค€์œผ๋กœ item์„ ์–ด๋–ป๊ฒŒ ์ •๋ ฌํ•  ๊ฒƒ์ธ๊ฐ€ >>>> justify-content

      ๋ฉ”์ธ์ถ•์„ ๊ธฐ์ค€์œผ๋กœ ์ค‘์‹ฌ, ์–‘์ชฝ์ •๋ ฌ ๋“ฑ

  3. ์„œ๋ธŒ์ถ•์„ ๊ธฐ์ค€์œผ๋กœ item์„ ์–ด๋–ป๊ฒŒ ์ •๋ ฌํ•  ๊ฒƒ์ธ๊ฐ€ >>>> align-items

     ์„œ๋ธŒ์ถ•์„ ๊ธฐ์ค€์œผ๋กœ ์ค‘์‹ฌ, ์–‘์ชฝ์ •๋ ฌ ๋“ฑ

- item์— ์ž‘์„ฑํ•ด์•ผ ํ•˜๋Š” ์š”์†Œ

  1. flex-basis : ์•„์ดํ…œ์˜ ๊ธฐ๋ณธ์ ์ธ ํฌ๊ธฐ ์„ค์ •

 

 

flex ์‹ค์Šต โ–ผโ–ผโ–ผโ–ผ

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .container{
            background-color: whitesmoke;
            height: 500px;

            /* container์— ์ž‘์„ฑํ•ด์•ผํ•˜๋Š” ์š”์†Œ 
                => ๋‚ด๋ถ€์— ๋“ค์–ด๊ฐ€๋Š” item์„ ์–ด๋–ป๊ฒŒ ์ •๋ ฌ์‹œํ‚ฌ์ง€!!! */

            /* (1) display:flex
                => flex ์„ค์ •, flex์™€ ๊ด€๋ จ๋œ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•จ
                ๋””ํดํŠธ : ํ•œ ์ค„์— ์—ฌ๋Ÿฌ๊ฐœ์˜ ์š”์†Œ๊ฐ€ ๋“ค์–ด๊ฐ (์ค„ ๋„˜์–ด๊ฐ€์ง€ X)
            */
            display: flex;

            /* (2) ๋ฐฐ์น˜๋ฐฉํ–ฅ ์„ค์ • */

            /* 2-1) column, column-reverse(์•„๋ž˜๋ถ€ํ„ฐ ์ •๋ ฌ)
            -       ๋ฉ”์ธ์ถ• :  ์„ธ๋กœ๋กœ ์ •๋ ฌ
            -       ์„œ๋ธŒ์ถ• : ๊ฐ€๋กœ(์ˆ˜ํ‰) */
            flex-direction: column;

            /* 2-2) row, row-reverse(์˜ค๋ฅธ์ชฝ๋ถ€ํ„ฐ ์ •๋ ฌ) 
            -       ๋ฉ”์ธ์ถ• : ๊ฐ€๋กœ๋กœ ์ •๋ ฌ
            -       ์„œ๋ธŒ์ถ• : ์„ธ๋กœ(์ˆ˜์ง)
            */
            flex-direction: row;

            /* (3) ๋ฉ”์ธ์ถ• ์ •๋ ฌ : justify-content */
            justify-content: center;

            /* (4) ์„œ๋ธŒ์ถ• ์ •๋ ฌ : align-items */
            align-items: center;
        }

        .item{
            background-color: skyblue;
            width: 100px;
            height: 100px;
            border: 1px solid navy;

            /* item ์š”์†Œ์—๊ฒŒ ์ž‘์„ฑํ•ด์•ผ ํ•˜๋Š” ๊ฒƒ */
            /* flex-basis : ์•„์ดํ…œ์˜ ๊ธฐ๋ณธ์ ์ธ ํฌ๊ธฐ ์„ค์ • */
            flex-basis: 15%;
        }

        #center{
            flex-basis: 70%;

            /* ์ฒซ ๊ตฌ์กฐ๋ฅผ ์žก์„ ๋•Œ๋Š” item์˜ ์—ญํ• 
                ๋‘๋ฒˆ์งธ ๊ตฌ์กฐ๋ฅผ ์žก์„ ๋•Œ๋Š” ('์•ˆ๋…•ํ•˜์„ธ์š”' ์˜ฎ๊ธธ๋•Œ)
                container์˜ ์—ญํ•  */
            display:flex;
            /* ๋ฐฐ์น˜๋ฐฉํ–ฅ - ๋””ํดํŠธ๊ธฐ ๋•Œ๋ฌธ์— ์ƒ๋žต ๊ฐ€๋Šฅ */
            flex-direction: column;
            /* ๋ฉ”์ธ์ถ• ์ •๋ ฌ */
            justify-content: center;
            /* ์„œ๋ธŒ์ถ• ์ •๋ ฌ */
            align-items: center;
        }

    </style>
</head>
<body>
    <!-- flex๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ, container์™€ item์„ ๊ตฌ๋ถ„ํ•ด์„œ ์‚ฌ์šฉํ•  ์˜ˆ์ •
    - ๋‚ด๊ฐ€ ์œ„์น˜๋ฅผ ์˜ฎ๊ฒจ์ฃผ๊ฑฐ๋‚˜, ๋ ˆ์ด์•„์›ƒ์„ ๋ฐ”๊พธ๊ณ  ์‹ถ์€ ์š”์†Œ : item
    - ๊ทธ item์ด ์†ํ•ด์žˆ๋Š” ๋ถ€๋ชจ ์š”์†Œ : container
        * container์™€ item์˜ ๊ด€๊ณ„๋Š” ์ ˆ๋Œ€์ ์ด์ง€ X 
    -->

    <div class="container">
        <div class="item"></div>
        <div class="item" id="center">
            <span>์•ˆ๋…•ํ•˜์„ธ์š”?</span>
            <!-- Q. ์•ˆ๋…•ํ•˜์„ธ์š”? ๋ผ๋Š” ๊ธ€์ž๋ฅผ ๋‘๋ฒˆ์งธ ๊ณต๊ฐ„์˜ ๊ฐ€์šด๋ฐ๋กœ ์œ„์น˜์‹œํ‚ค๊ธฐ -->
        </div>
        <div class="item"></div>
    </div>
</body>
</html>

 

์ƒ๋‹จ๋ฐ” ๋งŒ๋“ค๊ธฐ ์‹ค์Šต โ–ผโ–ผโ–ผโ–ผ

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* ์ž„์‹œ์ž‘์„ฑ =>  ๋‚˜์ค‘์— ์ง€์šฐ๊ธฐ! */
        /* .container div{
            border: 1px solid black;
        } */

        .container{
            background-color: whitesmoke;
            height: 100px;

            display: flex;
            justify-content: center;
        }

        .box{
            flex-basis: 20%;

            display: flex;
            justify-content: center;
            align-items: center;
        }

        #center{
            flex-basis: 60%;
            font-weight: 900;
        }

        a{
            color: black;

            text-decoration: none;
            box-sizing: border-box;
            padding: 0 15px 0 15px;
        }

        #left{
            font-size: 14px;
            box-sizing: border-box;
            /* padding: 20px; */
        }

    </style>
</head>
<body>

    <!-- ์ƒ๋‹จ๋ฐ” ์ „์ฒด ์˜์—ญ -->
    <div class="container">
        <div class="box" id="left">
            <h1>์ฅฌ๋ผ๊ธฐ์›”๋“œ</h1>
        </div>
        <div class="box" id="center">
            <a href="#">๋ฉ”๋‰ด</a>
            <a href="#">๋ฒ ์ŠคํŠธ</a>
            <a href="#">๋‰ด์Šค</a>
        </div>
        <div class="box" id="right">
            <a href="#">๋กœ๊ทธ์ธ</a>
            <a href="#">ํšŒ์›๊ฐ€์ž…</a>
        </div>
    </div>

</body>
</html>