Created
November 17, 2019 14:59
-
-
Save JodiWarren/9f88da67e229eaaa5a26dfa0b76278a2 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
<style> | |
.measurement-container { | |
position: fixed; | |
z-index: 999; | |
top: 30px; | |
left: 30px; | |
background: white; | |
padding: 15px; | |
border: 10px solid wheat; | |
} | |
</style> | |
<div class="measurement-container"> | |
<p>hello</p> | |
</div> | |
<script> | |
const heightContainer = document.querySelector('.measurement-container'); | |
function displayHeights(){ | |
const innerHeight = window.innerHeight; | |
const outerHeight = window.outerHeight; | |
const boundingClientHeight = document.body.getBoundingClientRect().height; | |
const screenHeight = window.screen.height; | |
const screenAvailableHeight = window.screen.availHeight; | |
const measurements = ` | |
<table> | |
<tr><td>innerHeight</td><td>${innerHeight}</td></tr> | |
<tr><td>outerHeight</td><td>${outerHeight}</td></tr> | |
</table> | |
` | |
heightContainer.innerHTML = measurements; | |
} | |
displayHeights(); | |
window.addEventListener('scroll', displayHeights); | |
window.addEventListener('resize', displayHeights); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment