Skip to content

Instantly share code, notes, and snippets.

@JodiWarren
Created November 17, 2019 14:59
Show Gist options
  • Save JodiWarren/9f88da67e229eaaa5a26dfa0b76278a2 to your computer and use it in GitHub Desktop.
Save JodiWarren/9f88da67e229eaaa5a26dfa0b76278a2 to your computer and use it in GitHub Desktop.
<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