Last active
May 18, 2016 03:59
-
-
Save astromac/8325738 to your computer and use it in GitHub Desktop.
Positions content below a fixed header and does this everytime the window size changes
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 contentOffset() { | |
var droppx = /\d+/; | |
var navheight = $('header > .navbar').css('height'); | |
var subnavheight = $('header > .navbar + .sub-nav').css('height'); | |
var breadcrumbheight = $('.breadcrumb').css('height'); | |
var offset = 0; | |
if ($('.page-header').length > 0) { | |
var pageheaderheight = $('.page-header').css('height'); | |
offset = parseInt(navheight.match(droppx)) + parseInt(subnavheight.match(droppx)) + parseInt(breadcrumbheight.match(droppx)) + parseInt(pageheaderheight.match(droppx)) + 1; | |
} else { | |
offset = parseInt(navheight.match(droppx)) + parseInt(subnavheight.match(droppx)) + parseInt(breadcrumbheight.match(droppx)) + 1; | |
} | |
$('header + .container').css('margin-top', offset); | |
} | |
// Position content below fixed header and do this everytime the window size changes | |
contentOffset(); | |
$(window).resize(contentOffset); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment