margin: 10px auto;
Unlike paddings, CSS margins are not exactly a spacing measure when it is applied to an element inside. When you apply a margin to the elements like above, the top margin will tend to go outside of the parent element. It is just an example of the general margin collapsing behavior.
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Mastering_margin_collapsing
Therefore, in your code snippet, it's not only the body with the height of 100vh
that you see on the screen. It also includes 10px
of space right above the body element.
To resolve this issue, remove margin
from .container
and consider applying padding-top: 10px;
to the body element instead.