Vh and margin of css

I set html and body to 100vh
but scroll bars appear when setting margin in body

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <div class="app">
    <div class="f">
      <div class="s">
        
      </div>
    </div>
    <div class="f2">
    </div>
  </div>
</body>

<style>
  html,
  body,
  .app {
    margin: 0;
    padding: 0;
    height: 100vh;
  }

  * {
    box-sizing: border-box;
  }

  .app {
    height: 100%;
  }

  .s {
    margin: 10px 0;
    padding: 10px 10px;
    background-color: red;
  }

  .f2 {
    height: 50px;
    background-color: green;
  }
</style>

</html>

codepen

Mar.17,2021

1. Add border
2 to the parent box. Add padding-top
3 to the parent box Add overflow:hidden
4 to the parent box Parent box: position:fixed
5. Parent box: display:table
6. Add a sibling element to the front of the child element

 :content:"";
  overflow:hidden;

the margin-top of the bug, child element of margin-top will infiltrate into the parent. The .s you wrote, in fact, p has margin-top, and switch to padding

.
Menu