Last active
August 29, 2015 14:06
-
-
Save latentflip/32bab06aa41f81ee37e4 to your computer and use it in GitHub Desktop.
This file contains 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
function canCalcVh() { | |
//If we don't have this, calc + vh probably won't work anyway. | |
if (!window.getComputedStyle) return false; | |
//Create a div element | |
var dummyDiv = document.createElement('div'); | |
//Ensure it's not visible | |
dummyDiv.style.visibility = 'hidden'; | |
//Set a calc style on it | |
dummyDiv.style.height = 'calc(1px + 50vh)' | |
//Add it to the dom so it gets a style | |
document.body.appendChild(dummyDiv); | |
//Get it's actual computed height | |
var renderedHeight = parseInt(window.getComputedStyle(dummyDiv).height, 10); | |
//If it's > 0, then calc with vh must be working | |
return renderedHeight > 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment