Site logo

[Resolved] add space to one nav item to fill secondary menu edge to edge

Home Forums Support [Resolved] add space to one nav item to fill secondary menu edge to edge

Home Forums Support add space to one nav item to fill secondary menu edge to edge

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #2584709
    sparkle

    i saw in another thread, a person had luck with what i wanted, but it’s not working for me. i tried this code because i want to make a space after the 4th menu item that would pin the other menu items to the right…. so items 1,2,3,4 [flexible space here] 5,6,7,8 with items 1 & 8 being at the outer edges of the secondary menu container.

    ul#menu-constants li:nth-child(4) {
          margin-right: auto;
    }
    #2584752
    sparkle

    nevermind i found this https://docs.generatepress.com/article/centering-logo-navigation/ which i think i can get working for me.just gotta keep the logo big and the menu margins the same width as the page…

    #2584773
    Ying
    Staff
    Customer Support

    Glad you’ve figured it out 🙂

    #2585504
    sparkle

    oh wait…. i totally did NOT figure this out. i found the other technote for centering the logo on the primary nav on this site… but neither are working the way i want…. but if you could tell me how to get that gap in the secondary nav, that would be amazing. for the primary nav, i’m having trouble keeping the logo large but getting the other items to be spaced evenly and butting out to the outer edges of the container….

    #2585551
    David
    Staff
    Customer Support

    Hi there,

    can i see the site in question ?

    #2585557
    sparkle

    yes… sorry… 🙂 i had it in the original post…

    #2585582
    David
    Staff
    Customer Support

    No probs 🙂

    Add this to your CSS:

    .secondary-navigation .inside-navigation,
    .secondary-navigation .inside-navigation .main-nav {
        max-width: 100%;
        flex: 1;
    }
    #2587051
    sparkle

    ok! yay. THANK YOU! i still have a lot to learn about flex.

    for the desktop primary nav, i’ve got the logo centered per the technote above, but i’d like to restrain the logo to always be 30% of the site width and then have the other nav items all 11% width and text centered so it looks a little more like the second image here.

    https://imgur.com/a/gUYZZTi

    #2587217
    David
    Staff
    Customer Support

    The difficulty here is – it requires a lot wider navigation bar to work, as each menu item has to be the width of the widest menu item.

    For example:

    1. Remove this part of the CSS:

    .main-navigation ul li:nth-child(4) {
        margin-left: auto;
    }

    2. Add this CSS:

    
    /* set the width of the nav */
    .main-navigation .inside-navigation {
        max-width: 1560px;
    }
    /* define the space the logo requires */
    #menu-launch {
        --logo-width: 360px;
        justify-content: space-around !important;
    }
    /* insert a pseudo menu item behind the logo */
    /* this makes it so items cannot go behind the logo */
    #menu-launch:before {
        content: '';
        order: 2;
        flex-basis: var(--logo-width);
        margin: auto;
    }
    #menu-launch li:nth-last-of-type(-n+3) {
        order: 10;
    }
    /* Set the width of each menu item */
    #menu-launch li {
        flex: 0 1 calc( ( 100% - var(--logo-width) ) / 6 );
        text-align: center;
    }
    

    You will see i had to set the max-width to 1560px to keep the longest item inline.

    If you can reduce menu item widths / font sizes etc. then the max-width can be reduced.

    #2587454
    sparkle

    thanks so much for this. i appreciate the explanations and advice too. it looks great. you guys rock. lemme know when the GP tshirts are available for purchase!

    #2588559
    David
    Staff
    Customer Support

    You’re welcome

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