1. 박스사이징

image.png

image.png

image.png

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        box-sizing: border-box;
      }
      .box1 {
        display: inline-block;
        padding: 10px;
        width: 300px;
        height: 300px;
        border: 20px solid green;
      }
      .box2 {
        display: inline-block;
        width: 300px;
        height: 300px;
        border: 1px solid red;
      }
    </style>
  </head>
  <body>
    <h1>box-sizing</h1>
    <hr />

    <div class="box1"></div>
    <div class="box2"></div>
  </body>
</html>

2. 엘레멘트 초기화 코드

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

image.png