Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Center submenu under main nav

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #160152
    Mika23
    Participant

    I would like to have my submenu be centered under the main nav item it belongs to. Something as in the first link below. I’m able to center the items in the submenu, but for one or the other reason I’m not able to center the submenu (what drops down) under the menu item. Can someone help? Thanks!

    Link 1 (example): http://imgur.com/HvYfzDH

    Link 2 (my site): http://www.carinescloset.com/

    #160241
    Paulie_D
    Member

    I think this will work.

    Try adding this:

    #main-nav ul {
    width: 150%; 
    left: -25%;
    }
    

    The width figure is arbitrary, you just have to make it wide enough so that your submenu text fits inside each li

    The left value pulls the submenu into the middle.

    #160267
    Mika23
    Participant

    Thanks a lot for your help. This helped but sadly enough only for the first few menu elements. The last few (city, men, about) it doesn’t work anymore. Do you know why?

    #160268
    Paulie_D
    Member

    What do you mean by “doesn’t work”?

    #160281
    Mika23
    Participant

    Sorry, should have been more clear.

    For those 3 menu items the border of the sub-menu is still centered under the main nav item but the links in the submenu are not centered under main nav and also the submenu is now too small for the links. They go outside the border.

    #160285
    Paulie_D
    Member

    As I said, the numbers are arbitrary so you may have to adjust them., AFAIK the general principal should work, it’s just a matter of tweaking.

    #160307
    MikesBarto2002
    Participant

    What Paulie_D is saying is that for instance, for the “City” menu item, try:

    li {
      width: 200%;
      left: -50%;
    }
    
    #160363
    Mika23
    Participant

    OK, I’m still pretty new but did not think it was that difficult. I tried multiple bits of code but none work. Can you help out and let me know what I am doing wrong?

    li#menu-item-517.menu-item.menu-item-type-post_type.menu-item-object-page menu-item-has-children.menu-item-517 {
    width: 200% important!;
    left: -50% important!;
    }

    and

    menu-item-517 li {
    width: 200% important!;
    left: -50% important!;
    }

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘CSS’ is closed to new topics and replies.