WordPress.org

Ready to get started?Download WordPress

Forums

Patchwork
Center navigation menu, Patchwork theme (11 posts)

  1. primHel
    Member
    Posted 1 year ago #

    Hey guys,
    Does anybody know how to center the navigation menu? I'm using a child theme, and I don't want to hard-code anything (like adding a number to "left" or margins).

    Here's the site: http://www.primas2day.com/

    Any help will be greatly appreciated (-8

  2. Andrew
    Forum Moderator
    Posted 1 year ago #

    Are you certain menu items won't change name, be removed or added?

  3. primHel
    Member
    Posted 1 year ago #

    No, I'm not certain, so I want to keep the whole thing as flexible as possible :-)

  4. Andrew
    Forum Moderator
    Posted 1 year ago #

    If you're not certain, you can't have a centred menu.

  5. primHel
    Member
    Posted 1 year ago #

    ok, I'm not sure I'm following you on this, could you please elaborate?

  6. Andrew
    Forum Moderator
    Posted 1 year ago #

    Are you familiar with CSS block elements?
    To center a block element, you need to add a width.

  7. primHel
    Member
    Posted 1 year ago #

    sure, but say I'll add or remove one menu item now and then, so that the navigation menu might contain 3-5 items.

  8. Andrew
    Forum Moderator
    Posted 1 year ago #

    If the menu has 3 items and you have a width wide enough for 5, the menu will be off-set from the center.

  9. primHel
    Member
    Posted 1 year ago #

    Right, ok, so that pretty much means that I will have to hardcode something :-)

    Say I have four menu items, how do I go about centering the navigation menu then?

    BTW, thanks for taking the time, Andrew.

  10. Andrew
    Forum Moderator
    Posted 1 year ago #

    Say I have four menu items, how do I go about centering the navigation menu then?

    Look at the resource referenced above, "To center a block element". You need to add a margin: 0 auto; and a width: to the exact width of all menu items. Try adding this to your <ul> element in the Child Theme style.css file.

  11. primHel
    Member
    Posted 1 year ago #

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic