Advertisement
Guest User

Untitled

a guest
Jul 17th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. $(document).ready(function() {
  2. var NavY = $('.nav').offset().top;
  3.  
  4. var stickyNav = function(){
  5. var ScrollY = $(window).scrollTop();
  6.  
  7. if (ScrollY > NavY) {
  8. $('.nav').addClass('sticky');
  9. } else {
  10. $('.nav').removeClass('sticky');
  11. }
  12. };
  13.  
  14. stickyNav();
  15.  
  16. $(window).scroll(function() {
  17. stickyNav();
  18. });
  19. });
  20.  
  21. .sticky
  22. {
  23. width: 100%;
  24. position: fixed;
  25. left: 0;
  26. top: 0;
  27. z-index: 100;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement