Skip to content
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>
    #box1 {
      width: 100px;
      height: 100px;
      padding: 20px;
      border: 10px solid black;
      background-color: #bfa;
      position: relative;
    }
    #box2 {
      width: 100px;
      height: 100px;
      background-color: red;
      position: absolute;
      top: 10px;
      left: 10px;
    }
  </style>
</head>
<body>
  <!-- 
    两个嵌套的 div,父元素 relative,子元素absolute,子div设置 top 属性,那么这
    个 top 是相对于父元素的哪个位置定位的?

    答:父元素的 border 的内边框
   -->
  <div id="box1">
    <div id="box2"></div>
  </div>
</body>
</html>