HTML -- How can I "stick" my navbar after reaching a specific section on page?

John

I thought of 2 different methods to approaching this, but I need assistance.

  1. Scroll to section and then stick.
  2. Hide element while scrolling, then unhide element once you have reached point on page.

How can I do this?

I'm using stickyjs currently.

But I don't see a feature for doing what I asked.

Vitorino fernandes

demo - http://jsfiddle.net/m6q6j8xL/3/

this is custom js

in this demo the header changes to green(fixed) and when you reach to blue div changes back to normal and when u are out from the blue div it changes back to fixed

padding is added to div so that it doesn't effect window scroll when changed to fixed

var stickyNavTop = $('.header').offset().top;

function scrolling() {
    doc = $(document).height()
    hidingtop = $('.hiding').offset().top;
    hidingbottom = $('.hiding').position().top + $('.hiding').outerHeight(true) // finding the outer height
    if ($(window).scrollTop() > hidingtop && $(window).scrollTop() < hidingbottom) {
        $('.header').removeClass('sticky');
        $('.container').css('padding-top', '0');
    }
}

var stickyNav = function () {
    var scrollTop = $(window).scrollTop();

    if (scrollTop > stickyNavTop) {
        $('.header').addClass('sticky');
        $('.container').css('padding-top', '100px');
    } else {
        $('.header').removeClass('sticky');
        $('.container').css('padding-top', '0');
    }
};

stickyNav();

$(window).scroll(function () {
    stickyNav();
    scrolling()
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

HTML -- How can I make my navbar stick after scrolling to a certain point on page?

From Dev

How can I make my navbar appear at a certain section?

From Dev

How do I align my navbar to the right of my html page?

From Dev

How can I set an anchor link to a specific section in a page?

From Dev

How can I set an anchor link to a specific section in a page?

From Dev

How do I shift the page-scroll for each html section to jump to the top of each section upon clicking its corresponding link in the navbar?

From Dev

How can I make my left/right monitor configuration stick after a restart

From Dev

How can I to specific the css rules for Chrome and IE in my HTML page or in SCSS file?

From Dev

How can I make my navbar appear on every page in my rails app?

From Dev

How do I get my button group <div> to stick to the bottom of my navbar?

From Dev

how can i add this to my html page with jquery html()?

From Dev

How can I hide Section on home page?

From Dev

How can I write a bootloader of my operating system to a USB stick?

From Dev

How can I clone my entire OS to a bootable USB stick?

From Dev

How can i make my footer stick to bottom?

From Dev

How can I add a redirect for after my Facebook page is liked?

From Dev

How can I make my navbar responsive?

From Dev

How can I get my program to swap a string with the key that is pressed down in a specific section of the string?

From Dev

How can I get my program to swap a string with the key that is pressed down in a specific section of the string?

From Dev

Moving to a specific section on an HTML Page

From Dev

Moving to a specific section on an HTML Page

From Dev

How to I bring my sticky navbar in front of the contents on my page?

From Dev

How can i remove this sidebar from my html page?

From Dev

How can I output my webcam directly to a simple HTML page?

From Dev

How can I remove space at the top of my HTML page?

From Dev

How can I make my html page search engine friendly

From Dev

How can I hide a specific html section in IE8 only?

From Dev

Fullpage.js how can I link to another html page with <a> element in section

From Dev

How to update a specific section of html/jsp page on click of button?

Related Related

  1. 1

    HTML -- How can I make my navbar stick after scrolling to a certain point on page?

  2. 2

    How can I make my navbar appear at a certain section?

  3. 3

    How do I align my navbar to the right of my html page?

  4. 4

    How can I set an anchor link to a specific section in a page?

  5. 5

    How can I set an anchor link to a specific section in a page?

  6. 6

    How do I shift the page-scroll for each html section to jump to the top of each section upon clicking its corresponding link in the navbar?

  7. 7

    How can I make my left/right monitor configuration stick after a restart

  8. 8

    How can I to specific the css rules for Chrome and IE in my HTML page or in SCSS file?

  9. 9

    How can I make my navbar appear on every page in my rails app?

  10. 10

    How do I get my button group <div> to stick to the bottom of my navbar?

  11. 11

    how can i add this to my html page with jquery html()?

  12. 12

    How can I hide Section on home page?

  13. 13

    How can I write a bootloader of my operating system to a USB stick?

  14. 14

    How can I clone my entire OS to a bootable USB stick?

  15. 15

    How can i make my footer stick to bottom?

  16. 16

    How can I add a redirect for after my Facebook page is liked?

  17. 17

    How can I make my navbar responsive?

  18. 18

    How can I get my program to swap a string with the key that is pressed down in a specific section of the string?

  19. 19

    How can I get my program to swap a string with the key that is pressed down in a specific section of the string?

  20. 20

    Moving to a specific section on an HTML Page

  21. 21

    Moving to a specific section on an HTML Page

  22. 22

    How to I bring my sticky navbar in front of the contents on my page?

  23. 23

    How can i remove this sidebar from my html page?

  24. 24

    How can I output my webcam directly to a simple HTML page?

  25. 25

    How can I remove space at the top of my HTML page?

  26. 26

    How can I make my html page search engine friendly

  27. 27

    How can I hide a specific html section in IE8 only?

  28. 28

    Fullpage.js how can I link to another html page with <a> element in section

  29. 29

    How to update a specific section of html/jsp page on click of button?

HotTag

Archive