[Resolved] 2 line sticky navigation

Home Forums Support [Resolved] 2 line sticky navigation

Home Forums Support 2 line sticky navigation

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #447228
    Sean

    I’m trying to create navigation that looks somewhat like this when scrolled (site URL deleted). I gather from forum posts I’ve read here that it is not trivial to lock the top-bar or a secondary nav on top of the sticky navigation menu. Any suggestions for the best way to approach this?

    Also, is there any way to get the top bar appear only after scrolling on desktop, but on load for mobile?

    #447460
    Tom
    Lead Developer
    Lead Developer

    Hi Sean,

    You should be able to set this up with some custom CSS.

    Can you add the top bar to your site and then link me to it so I can write something up?

    Thanks!

    #447485
    Sean

    Thanks Tom! Here’s a staging demo site with the top bar added: http://www.tawaphysio.riedr.com/

    #448194
    Tom
    Lead Developer
    Lead Developer

    This is likely the only way to do it:

    .top-bar {
        position: sticky;
        top: 0;
        z-index: 200;
    }
    
    .main-navigation.navigation-stick {
        top: 39px !important;
    }

    Some browsers have poor support for position: sticky, in that case you can do this:

    .top-bar {
        position: fixed;
        left: 0;
        right: 0;
        top: 0;
        z-index: 200;
    }
    
    .main-navigation {
        top: 39px !important;
    }

    Let me know πŸ™‚

    #448338
    Sean

    That works great Tom for the desktopview. With the mobile menu though the top bar ends up covering up most of the mobile menu. Is there a way to slide the mobile menu down?

    #448908
    Tom
    Lead Developer
    Lead Developer

    I just adjusted the CSS above so it should apply on mobile as well πŸ™‚

    #448950
    Sean

    Thanks Tom, that works great for me on Firefox and Chrome. On Safari and Edge though the top bar does not appear. Are there some vendor prefixes I should be adding?

    #448952
    Tom
    Lead Developer
    Lead Developer

    Ugh, just bad browsers with bad support for position: sticky (which is a shame).

    You can do this if you need a more cross browser friendly solution:

    .top-bar {
        position: fixed;
        left: 0;
        right: 0;
        top: 0;
        z-index: 200;
    }
    #448962
    Sean

    Thanks Tom, that fixed the cross-browser issue for the sticky menu, but now I am getting overlap again between the top-bar and the desktop and mobile header. Any other options?

    #448965
    Tom
    Lead Developer
    Lead Developer
    #449054
    Sean

    Thanks for your help Tom!

    #449129
    Tom
    Lead Developer
    Lead Developer

    You’re welcome πŸ™‚

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.