Site logo

Archived topic

sticky header - with logo and both navs - possible?

22 replies · Started by sparkle on April 24, 2022

Viewing posts 1–15 of 23

hi again,

i've gotten the navigation layout just right and now it's been decided that we want the whole header to be sticky. i've tried with the header as navigation solution and also the sticky nav after looking through a lot of forum posts, but i can't seem to get the whole header to just stay in place when the user scrolls. any leads?

thanks as always!

:)

Hi Sparkle,

To clarify, are you wanting to make the secondary navigation sticky as well?

If so, you can try adding this custom CSS in Appearance > Customize > Additional CSS:

@media (min-width: 769px) {
    nav#secondary-navigation {
        position: sticky;
        top: 0;
        left: 0;
    }

    nav#sticky-navigation {
        top: 24.188px !important;
    }
}

This code would make the secondary navigation sticky on Table and Desktop views.

Kindly let us know how it goes, and if any modification is needed. Hope to hear from you soon. :)

Hi there,

theres an alternative option involving moving the Secondary Navigation inside the primary nav container. It may take a little CSS to tweak stuff but it means you can just use the GP Sticky Nav for a sticky header.

Is that something you would be interested in trying ?

If so the basics of doing so are here:

https://generatepress.com/forums/topic/anchor-text-is-hidden-behind-the-menu/#post-2175481

And the only additional change would be to set Customizer > Layout > Header --> Navigation as Header.

i'll give it a shot!

is the hook called generate_inside_header now?

ah.. yeah, i did try this before but had really bad luck styling and gave up because i'd just done all that work to style the header >just right< when i didn't realize sticky was the preference. i couldn't get the main nav to stay on the same line as the logo and get the placement above the top line of the logo. i will keep trying.

No - the generate_inside_navigation should still be in the list

thank you. i currently have it set correctly. i was checking because all the hooks now seem to have generate_ in front of them. i actually typed the wrong one.

Sorry that was my bad... all GP hooks are prefixed with generate_. Did it work ?

no. i'm really struggling. the logo disappears when main nav comes up and when the sticky nav appears and i can't seem to get the styling right. the primary nav falls below the header/branding and ultimately, i just want the logo, primary nav and secondary nav locked in place at the top. there's still some picky spacing to sort with the icons. i've still got the original secondary nav up there for reference, but will remove it with the customizer once i get it right.

also, when i try to make the login in the sticky header as big as the one in my original nav, it's smaller, despite putting in the same pixel width. so frustrating.

Solest throw a little CSS at it to make sure the logo keeps its size and it aligns bottom with the primary nav:

.navigation-branding img, .site-logo.mobile-header-logo img {
    height: 120px;
    bottom: -30px;
}

The height will fix the logo size.
And the bottom is pulling the logo down 30px.

that didn't change anything? it's like the logo in the primary navigation is completely missing. do i have a setting checked wrong somewhere?

This archived topic is closed to new replies.