Last active
August 29, 2015 14:21
-
-
Save benknight/0a13088c4f152639ed97 to your computer and use it in GitHub Desktop.
100vh workaround
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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