Jieunny์˜ ๋ธ”๋กœ๊ทธ

Unit5. [์‹ค์Šต] Flexbox ์‚ฌ์šฉ ๋ณธ๋ฌธ

CodeStates/Training

Unit5. [์‹ค์Šต] Flexbox ์‚ฌ์šฉ

Jieunny 2022. 12. 19. 12:17

๐Ÿ“ฃ Flexbox ์‚ฌ์šฉํ•ด์„œ VScode ๋ ˆ์ด์•„์›ƒ ๋งŒ๋“ค์–ด๋ณด๊ธฐ

 

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Practice</title>
  <link rel="stylesheet" href="index.css" />
</head>
<body>
    <div class="container">
        <div class="col wrap1">	
            <div class="row icon">icon1</div>
            <div class="row icon">icon2</div>
            <div class="row icon">icon3</div>
        </div>
        <div class="col wrap2">
            <div class="row h50">box1</div>
            <div class="row h30">box2</div>
            <div class="row h20">box3</div>
        </div>
        <div class="col wrap3">
            <div class="row h80">box1</div>
            <div class="row h20">box2</div>
        </div>
    </div>

</body>
</html>
html {
    height: 100%;	
    /* ๋ฐ•์Šค๋“ค์„ ํ™”๋ฉด์— ๊ฝ‰ ์ฑ„์šฐ๊ธฐ ์œ„ํ•ด์„œ ๋ถ€๋ชจ์š”์†Œ ๋†’์ด ์ฃผ๊ธฐ */
}

body {
    margin: 0;
    padding: 0;
    background: #fff;
    color: #4a4a4a;
    height: 100%;
    /* ๋ฐ•์Šค๋“ค์„ ํ™”๋ฉด์— ๊ฝ‰ ์ฑ„์šฐ๊ธฐ ์œ„ํ•ด์„œ ๋ถ€๋ชจ์š”์†Œ ๋†’์ด ์ฃผ๊ธฐ */
  }

  .container {
    width: 100%;
    /* ํ™”๋ฉด์— ๊ฐ€๋กœ ๊ฝ‰ ์ฑ„์šฐ๊ธฐ */
    height: 100%;
    /* ํ™”๋ฉด์— ์ƒˆ๋กœ ๊ฝ‰ ์ฑ„์šฐ๊ธฐ */
    display: flex;
    /* ์ž์‹ ์š”์†Œ์ธ 3๊ฐœ์˜ div๋ฅผ ๊ฐ€๋กœ๋กœ ๋ฐฐ์น˜ํ•˜๊ธฐ ์œ„ํ•ด ๋ถ€๋ชจ์š”์†Œ์— flex ์ฃผ๊ธฐ */
  }

  .col {
    border: 1px solid red;
  }

  .row {
    border: 1px solid blue;
    margin: 3px;
  }

  .wrap1 {
    flex : 1;
    /* ์„ธ div ์š”์†Œ์˜ ๊ฐ€๋กœ ํฌ๊ธฐ ๋น„์œจ ์„ค์ •ํ•ด์ฃผ๊ธฐ */
    padding: 5px;
    margin: 1px;
  }

  .wrap2 {
    flex : 2;
    /* ์„ธ div ์š”์†Œ์˜ ๊ฐ€๋กœ ํฌ๊ธฐ ๋น„์œจ ์„ค์ •ํ•ด์ฃผ๊ธฐ */
    padding: 5px;
    box-sizing: border-box;
    margin: 1px;
    display: flex;
    /* ์ž์‹ ์š”์†Œ๋ฅผ ์„ธ๋กœ๋กœ ๋ฐฐ์น˜์‹œ์ผœ ํฌ๊ธฐ ๋น„์œจ์„ ์ง€์ •ํ•ด์ฃผ๊ธฐ ์œ„ํ•ด ๋ถ€๋ชจ์š”์†Œ์— flex ์ฃผ๊ธฐ */
    flex-direction: column;
    /* ์ž์‹ ์š”์†Œ ์„ธ๋กœ๋กœ ๋ฐฐ์น˜ */
  }

  .wrap3 {
    flex : 7;
    /* ์„ธ div ์š”์†Œ์˜ ๊ฐ€๋กœ ํฌ๊ธฐ ๋น„์œจ ์„ค์ •ํ•ด์ฃผ๊ธฐ */
    padding: 5px;
    margin: 1px;
    display: flex;
    /* ์ž์‹ ์š”์†Œ๋ฅผ ์„ธ๋กœ๋กœ ๋ฐฐ์น˜์‹œ์ผœ ํฌ๊ธฐ ๋น„์œจ์„ ์ง€์ •ํ•ด์ฃผ๊ธฐ ์œ„ํ•ด ๋ถ€๋ชจ์š”์†Œ์— flex ์ฃผ๊ธฐ */
    flex-direction: column;
    /* ์ž์‹ ์š”์†Œ ์„ธ๋กœ๋กœ ๋ฐฐ์น˜ */
  }
  
  /* ํฌ๊ธฐ ๋น„์œจ ์ง€์ •ํ•ด์ฃผ๊ธฐ */

  .h80 {
    flex: 8;
  }

  .h50 {
    flex: 5;
  }

  .h30 {
    flex: 3;
  }

  .h20 {
    flex: 2;
  }

  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }