Last active
December 18, 2015 05:09
-
-
Save catdad/5730782 to your computer and use it in GitHub Desktop.
Displays the browser viewport for dev purposes
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
(function viewport(){ | |
//create element | |
var el = document.createElement("div"); | |
//style as you wish | |
el.id = 'screenSize'; | |
el.style.position = "fixed"; | |
el.style.width = "100%"; | |
el.style.left = "0px"; | |
el.style.bottom = "5px"; | |
el.style.color = "#35b4e3"; | |
el.style.textAlign = "center"; | |
el.style.font = "normal bold 100% sans-serif"; | |
//gets size | |
function getSize(){ return window.innerWidth + ' x ' + window.innerHeight; } | |
//displays size | |
function displaySize(){ el.innerHTML = getSize(); } | |
//insert element | |
document.body.appendChild(el); | |
//innitial sizing | |
displaySize(); | |
//resize listener | |
window.onresize = displaySize | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment