Skip to content

Instantly share code, notes, and snippets.

@nester999
Forked from mklickman/viewport-width.js
Created January 13, 2014 18:43
Show Gist options
  • Save nester999/8405707 to your computer and use it in GitHub Desktop.
Save nester999/8405707 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
var $counter = $('<p class="viewport-width-counter" />');
$('html').append($counter);
if ($('p.viewport-width-counter').length) {
$counter.css({
'position': 'fixed',
'top': 0,
'left': 0,
'padding': 5,
'border-radius': '0 0 3px 0',
'background': '#999',
'font-family': 'sans-serif',
'margin': 0,
'box-shadow': 'rgba(0, 0, 0, 0.6) 1px 1px 0px',
'color': 'white',
'z-index': 9999
});
var updateViewportWidthCounter = function() {
$counter.text($(window).width());
}
updateViewportWidthCounter();
$(window).on('resize', updateViewportWidthCounter);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment