Last active
May 19, 2020 19:01
-
-
Save resultakak/f07526a072d31349cb87ac1e5120ca80 to your computer and use it in GitHub Desktop.
Sticky Header
This file contains 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
// 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'); | |
}); |
This file contains 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
/** 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