A safer way to vertically fill the viewport

Categories

Using min-height: 100vh works great for filling the viewport, but a safer way is to progressively use -webkit-fill-available to account for a long-standing iOS issue with 100vh.

Code language
CSS
html {
  height: -webkit-fill-available;
}

body {
  min-height: 100vh;
  min-height: -webkit-fill-available;
}

This is by no means a perfect fix, but it’s a little more acceptable if you need docked elements on your page.

For more info on the iOS issue, be sure to check out Nicolas Hoizey’s extremely detailed log. See this handy demo, too.

Hello, I’m Andy and I’ll help you build fast, accessible websites & design systems.

I’m a freelance CSS and design systems consultant, based in the UK. I specialise in design systems and creative web design, such as landing pages and campaign work.

I’m currently helping Google by refactoring the CSS and creating a design system for web.dev, but I have availability for projects such as small websites, landing pages and consultancy. I will have full availability for larger projects in January 2022.

Hire me