Skip to content

Instantly share code, notes, and snippets.

@ahgood
Created June 15, 2016 03:27
Show Gist options
  • Save ahgood/bd20d635cdf4b37f29c102df4eda39d1 to your computer and use it in GitHub Desktop.
Save ahgood/bd20d635cdf4b37f29c102df4eda39d1 to your computer and use it in GitHub Desktop.
//CSS effect: -webkit-transition: all 0.4s ease; transition: all 0.4s ease;
jQuery('h2:contains("KEY")').parent().attr('id', 'sticky-nav');
jQuery('head').append('<style>.sticky-nav {width: 100%;position: fixed;top: 0;background-color: #fff;text-align: center;}.sticky-nav > div {float: none; display: inline-block;}</style>');
jQuery(window).scroll(function() {
if (jQuery(this).scrollTop() > 428 && $(this).scrollTop() < 3827){
jQuery('#sticky-nav').addClass('sticky-nav');
} else{
jQuery('#sticky-nav').removeClass('sticky-nav');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment