Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- var NavY = $('.nav').offset().top;
- var stickyNav = function(){
- var ScrollY = $(window).scrollTop();
- if (ScrollY > NavY) {
- $('.nav').addClass('sticky');
- } else {
- $('.nav').removeClass('sticky');
- }
- };
- stickyNav();
- $(window).scroll(function() {
- stickyNav();
- });
- });
- .sticky
- {
- width: 100%;
- position: fixed;
- left: 0;
- top: 0;
- z-index: 100;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement