Skip to content

Instantly share code, notes, and snippets.

@resultakak
Last active May 19, 2020 19:01
Show Gist options
  • Save resultakak/f07526a072d31349cb87ac1e5120ca80 to your computer and use it in GitHub Desktop.
Save resultakak/f07526a072d31349cb87ac1e5120ca80 to your computer and use it in GitHub Desktop.
Sticky Header
// https://jsfiddle.net/gxRC9/502/
// var stickyOffset = $('.sticky').offset().top;
$(window).scroll(function(){
var sticky = $('.sticky'),
scroll = $(window).scrollTop();
// if (scroll >= stickyOffset) sticky.addClass('fixed');
if (scroll >= 200) sticky.addClass('fixed');
else sticky.removeClass('fixed');
});
/** https://jsfiddle.net/gxRC9/502/ **/
.fixed {
position: fixed !important;
top:0; left:0;
width: 100%; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment