Percentage values of inner and outer margins

The percentage values ​​of the inner and outer margins are calculated relative to the width of the parent element.

Code:

<!DOCTYPE html>
<html>

<head>
  <style>
    .a {
     
     
      width: 200px;
      height: 200px;
      border: 1px solid black;
    }

    .b {
     
     
      width: 50px;
      height: 50px;
      padding: 10%;
      margin: 10%;
      background-color: red;
    }
  </style>
</head>

<body>
  <div class="a">
    <div class="b"></div>
  </div>
</body>

</html>

Show results:
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44645309/article/details/111999050