Skip to content

Instantly share code, notes, and snippets.

@richmilns
Created July 1, 2015 13:09
Show Gist options
  • Save richmilns/930554488e9bfb61594f to your computer and use it in GitHub Desktop.
Save richmilns/930554488e9bfb61594f to your computer and use it in GitHub Desktop.
Display viewport dimensions
(function($) {
$(document).ready(showViewportSize);
$(window).resize(showViewportSize);
$('body').append('<div id="viewport__sizes"><span id="viewport__width"></span>x<span id="viewport__height"></span>');
$('#viewport__sizes').css({
'font-family':'arial',
'font-size':'30px',
'color':'rgba(0,0,0,0.3)',
'z-index':'9999',
'position':'fixed',
'right':'20px',
'bottom':'20px'
});
function showViewportSize() {
var w = $(window).width();
var h = $(window).height();
$('#viewport__width').text(w);
$('#viewport__height').text(h);
}
})(jQuery)
@richmilns
Copy link
Author

Use http://mrcoles.com/bookmarklet/ to make this into a bookmarklet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment