Skip to content

Instantly share code, notes, and snippets.

@benknight
Last active August 29, 2015 14:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benknight/0a13088c4f152639ed97 to your computer and use it in GitHub Desktop.
Save benknight/0a13088c4f152639ed97 to your computer and use it in GitHub Desktop.
100vh workaround
var mediaQueryList = window.matchMedia('(orientation: portrait)');
function setMaxHeight (mediaQueryList) {
var vh = window.innerHeight;
var vw = window.innerWidth;
var header = document.querySelector('.site-header');
if (mediaQueryList.matches) {
header.style.height = Math.max(vh, vw);
} else {
header.style.height = Math.min(vh, vw);
}
}
setMaxHeight(mediaQueryList);
mediaQueryList.addListener(setMaxHeight);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment