As @Mostafa Baezid said, there are default margins of body
.
Also, due to margin collasping on the vertical axis, you need to ensure that the topmost or downmost element's margin doesn't collapse, rendering the margin out of the parent.
What's more, 100vh != 100%
as for some mobile broswers. The menu bar of mobile browsers takes up some space and 100vh
doesn't reduce that space.
So what to do:
- Remove
body
margin (margin-top
and margin-bottom
would be enough)
- Remove the topmost element's
margin-top
and the downmost element's margin-bottom
. (you can use padding
instead)
- Use
height: 100%
instead of height: 100vh;
for mobile.