Skip to content

Instantly share code, notes, and snippets.

@jarekt
Last active January 2, 2022 17:48
Show Gist options
  • Save jarekt/853055b0cc79c1916c485802b7919f67 to your computer and use it in GitHub Desktop.
Save jarekt/853055b0cc79c1916c485802b7919f67 to your computer and use it in GitHub Desktop.
Fix viewport height size on mobile webkit browsers
* {
min-height: 100vh;
min-height: calc(var(--vh, 1vh) * 100);
}
// fixes vh units on mobile webkit based browsers
function fixVhSize() {
//get 1% of viewport height
let vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', `${vh}px`);
}
fixVhSize();
window.addEventListener("resize", fixVhSize);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment