Skip to content

Instantly share code, notes, and snippets.

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 wykydtronik/9f3efa56b50841280811b2ef8696b12b to your computer and use it in GitHub Desktop.
Save wykydtronik/9f3efa56b50841280811b2ef8696b12b to your computer and use it in GitHub Desktop.
/**
* bodymargin.js
*
* Dynamic margin-top for body element.
*/
if (typeof jQuery === 'undefined') {
throw new Error('Flation Theme\' requires jQuery')
}
+function($)
{
$(document).ready(function(){
if ( $("body").width() > 992 ) {
var margintop = $("#navbar").height() + 20;
$("body").css('margin-top', margintop);
}
if ( $('#wpadminbar').length && $("body").width() < 600 ) {
$(window).scroll(function(){
var bo = $("body").scrollTop();
if ( bo > 46 ) {
$(".navbar").css('top', "0");
} else {
$(".navbar").css('top', "46px");
}
});
}
});
}(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment