Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <header class="sticky"></header>
- $(window).scroll(function() {
- var windowTop = $(window).scrollTop();
- //check to see if we have scrolled past the original location of the sticky element
- if (windowTop > stickyTop) {
- //if so, change the sticky element to fised positioning
- $(".sticky").css({
- "position": "fixed",
- "top": 0
- });
- } else {
- $(".sticky").css({
- "position": "static"
- });
- }
Add Comment
Please, Sign In to add comment