Skip to content

Instantly share code, notes, and snippets.

@shehabkhan013
Created December 17, 2017 20:17
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 shehabkhan013/f7706b2dc568fbefdf9301de167f3039 to your computer and use it in GitHub Desktop.
Save shehabkhan013/f7706b2dc568fbefdf9301de167f3039 to your computer and use it in GitHub Desktop.
// Check the initial Poistion of the Sticky Header
var stickyHeaderTop = $('#stickyheader').offset().top;
$(window).scroll(function(){
if( $(window).scrollTop() > stickyHeaderTop ) {
$('#stickyheader').css({position: 'fixed', top: '0px'});
$('#stickyalias').css('display', 'block');
$('#stickyheader').addClass('fix-top');
} else {
$('#stickyheader').css({position: 'static', top: '0px'});
$('#stickyalias').css('display', 'none');
$('#stickyheader').removeClass('fix-top');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment