HTML and Body Height vs Viewport
How to match the height of your html and body to the height of your viewport.
Apr 6, 2024
So I had this weird issue.
The body wasn’t filling the viewport of certain screensizes.
After literally hours of scouring through the internet, I got a solution that worked from this rather old stackoverflow solution.
STEPS I TOOK
- Give a height of 100% to both html and body tags
- Give the main wrapper of the page a min-height of 100%
- The above solves the problem. But to make sure the content stretches all the way to the end, you can combine display of flex, flex direction of column and justify content of space-between
Hopefully this helps someone.
And yeah, I’m scared of heights, no pun intended.