Skip to content

Instantly share code, notes, and snippets.

@resting
Forked from Rafailong/script.js
Created August 19, 2014 08:07
Show Gist options
  • Save resting/5286af9f5a2e1b5ed410 to your computer and use it in GitHub Desktop.
Save resting/5286af9f5a2e1b5ed410 to your computer and use it in GitHub Desktop.
Div full Width/Height of viewport with jQuery
// global vars
var winWidth = $(window).width();
var winHeight = $(window).height();
// set initial div height / width
$('div').css({
'width': winWidth,
'height': winHeight,
});
// make sure div stays full width/height on resize
$(window).resize(function(){
$('div').css({
'width': winWidth,
'height': winHeight,
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment