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

Liam Docherty

Problem:

How can I make my navigation not appear on my #home section. However, when the user scrolls down or clicks on the find more button. When the user gets to the 'features-icons' section how can I make my navigation bar appear for all sections including that and below? https://github.com/ldocherty1/Unit28_Assignment1

What I have tried:

HTML

<nav class="navbar scrolled-nav fixed-top navbar-expand-sm bg-light">
    <a class="navbar-brand" href="#">Front End Web Developer</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-collapse">☰</button>
    <div class="collapse navbar-collapse" id="navbar-collapse">
        <ul class="nav navbar-nav ml-auto">
            <li class="nav-item active"> <a class="nav-link" href="#home">Home</a>
            </li>
            <li class="nav-item">
                <a class="nav-link active" href="#features-icons">Expectations</a>
            </li>
            <li class="nav-item active"> <a class="nav-link" href="#testimonials">Testimonials</a>
            </li>
            <li class="nav-item"> <a class="nav-link" href="#about">About</a>
            </li>
            <li class="nav-item"> <a class="nav-link" href="#portfolio">Portfolio</a>
            </li>
            <li class="nav-item"> <a class="nav-link" href="#about">Design</a>
            </li>
            <li class="nav-item"> <a class="nav-link" href="#contact">Contact</a>
            </li>
        </ul>
    </div>
</nav>

CSS

.navbar {
    display: none;
}

JS

$("body, html").on("scroll", function() {
    var features_top = $("#features-icon").position().top;
    var top_of_window = $(window).scrollTop();
    if (top_of_window >= features_top) {
        $(".navbar").show();
    } else {
        $(".navbar").hide();
    }
});

I believe it has something has to do with the JS part of my code the problem why my navbar isn't displaying.

Sabbin

Your navbar is not displaying because you never reach the point where the top_of_window >= features_top is valid.

I've updated the fiddle in the comment. Check it now https://jsfiddle.net/8o7omnm7/33/

Your navbar will be displayed only when the <div id="features-icon">Hola</div> will have -1px from top. As long as you don't have that it will not be displayed

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to make a navbar appear in certain section of the page? (bootstrap too)

From Dev

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

From Dev

How can I make my navbar responsive?

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 app appear in UIActivityViewController for text?

From Dev

How can i make my app appear on tablets

From Dev

How can I make my OS appear as if it is running virtualized?

From Dev

How can I make this section of my webpage responsive?

From Dev

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

From Dev

How can i make my functions stops executing at a certain line?

From Dev

How can I make my table scroll to a certain position?

From Dev

How can i make the 'poo' appear in a certain place when the screen is touched?

From Dev

How can i make the 'poo' appear in a certain place when the screen is touched?

From Dev

How can I make a waiting icon appear in the middle of my page with twitter bootstrap 3?

From Dev

How can I make an icon appear next to my title in the <title> tag?

From Dev

How can I make my MsgBox Appear if the Equip_No is not equal to the value in the Equip_no Textbox?

From Dev

How can I make my output appear all on one line with no spaces?

From Dev

How can I make a back button appear only if the user navigated to the page from my website?

From Dev

How can I make an icon appear next to my title in the <title> tag?

From Dev

How can i use the visibility attribute in css to make my submenu appear and reappear?

From Dev

How can I make my MsgBox Appear if the Equip_No is not equal to the value in the Equip_no Textbox?

From Dev

How do I write a swift array that can make the same UIImage appear for all my dynamic cells?

From Dev

How can I make my JS script calls in Magento appear on one line?

From Dev

TkInter: how can I make objects appear on my second window rather than the first?

From Dev

How can I make , a footer section, visible only in my wordpress frontpage?

From Dev

How can I make , a footer section, visible only in my wordpress frontpage?

From Dev

How can I make certain properties of my EF code-first classes internal to my DAL?

From Dev

How can I make certain properties of my EF code-first classes internal to my DAL?

From Dev

How can I make an element appear (for instance a tick) when a certain amount of characters have been typed into an input field?

Related Related

  1. 1

    How to make a navbar appear in certain section of the page? (bootstrap too)

  2. 2

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

  3. 3

    How can I make my navbar responsive?

  4. 4

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

  5. 5

    How can I make my app appear in UIActivityViewController for text?

  6. 6

    How can i make my app appear on tablets

  7. 7

    How can I make my OS appear as if it is running virtualized?

  8. 8

    How can I make this section of my webpage responsive?

  9. 9

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

  10. 10

    How can i make my functions stops executing at a certain line?

  11. 11

    How can I make my table scroll to a certain position?

  12. 12

    How can i make the 'poo' appear in a certain place when the screen is touched?

  13. 13

    How can i make the 'poo' appear in a certain place when the screen is touched?

  14. 14

    How can I make a waiting icon appear in the middle of my page with twitter bootstrap 3?

  15. 15

    How can I make an icon appear next to my title in the <title> tag?

  16. 16

    How can I make my MsgBox Appear if the Equip_No is not equal to the value in the Equip_no Textbox?

  17. 17

    How can I make my output appear all on one line with no spaces?

  18. 18

    How can I make a back button appear only if the user navigated to the page from my website?

  19. 19

    How can I make an icon appear next to my title in the <title> tag?

  20. 20

    How can i use the visibility attribute in css to make my submenu appear and reappear?

  21. 21

    How can I make my MsgBox Appear if the Equip_No is not equal to the value in the Equip_no Textbox?

  22. 22

    How do I write a swift array that can make the same UIImage appear for all my dynamic cells?

  23. 23

    How can I make my JS script calls in Magento appear on one line?

  24. 24

    TkInter: how can I make objects appear on my second window rather than the first?

  25. 25

    How can I make , a footer section, visible only in my wordpress frontpage?

  26. 26

    How can I make , a footer section, visible only in my wordpress frontpage?

  27. 27

    How can I make certain properties of my EF code-first classes internal to my DAL?

  28. 28

    How can I make certain properties of my EF code-first classes internal to my DAL?

  29. 29

    How can I make an element appear (for instance a tick) when a certain amount of characters have been typed into an input field?

HotTag

Archive