Guest User

Untitled

a guest
Mar 24th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. <header class="sticky"></header>
  2.  
  3. $(window).scroll(function() {
  4. var windowTop = $(window).scrollTop();
  5.  
  6. //check to see if we have scrolled past the original location of the sticky element
  7. if (windowTop > stickyTop) {
  8.  
  9. //if so, change the sticky element to fised positioning
  10. $(".sticky").css({
  11. "position": "fixed",
  12. "top": 0
  13. });
  14. } else {
  15. $(".sticky").css({
  16. "position": "static"
  17. });
  18. }
Add Comment
Please, Sign In to add comment