Skip to content

Instantly share code, notes, and snippets.

@jamosaur
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamosaur/9618485 to your computer and use it in GitHub Desktop.
Save jamosaur/9618485 to your computer and use it in GitHub Desktop.
responsive section heights
$(function(){
$('.section').each(function(){
var sectionHeight = $(':first-child', this).height();
if(sectionHeight > $(window).innerHeight())
{
$(this).css('height','auto');
}
else
{
$(this).css({ height: $(window).innerHeight() });
}
});
$(window).resize(function(){
$('.section').css({ height: "auto" });
$('.section').each(function(){
var pageHeight = $(':first-child', this).height();
if(pageHeight < $(window).innerHeight())
{
$(this).css('height', $(window).innerHeight());
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment