WordPress.org

Ready to get started?Download WordPress

Forums

Fighting new line in wp_nav_menu affecting inline-display of menu items (4 posts)

  1. diverchrisfl
    Member
    Posted 1 year ago #

    So, the new line being kicked out after the <li> in wp_nav_menu was causing a space between my menu items. I am using a background color change on hover that first pointed out the space.

    I have discovered that I can edit the nav-menu-template file in wp-includes and remove that /n on line 106.

    My question: will that change stick when WordPress next upgrades? Is there a way that I can address this through my child theme functions file instead of editing nav-menu-template?

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    No! Never, ever, edit WordPress core scripts. And do not encourage others to do so. Editing core scripts can bring down your entire site and/or open security holes for hackers to use.

    If a simple line return is causing a display problem in your site, then I would recommend that you start by checking your CSS.

  3. diverchrisfl
    Member
    Posted 1 year ago #

    Thanks for the rapid response, esmi, but I don't *think* the problem is in my CSS. I was led to the solution I mentioned above by reading css-display-inline-block-why-it-rocks-and-why-it-sucks.

    To re-state the problem: the inline-block property on the <li> tags was adding a space when rendering the nav-menu-template in Firefox 21.0. I wanted the list elements to meet with no space between them, and the normal methods of setting margin and padding to 0 did not work.

    Is it a better solution to use some menu plug-in? I am learning WordPress and gladly accept your never, ever injunction, but I can't be the first person to encounter this problem, either. Is there another solution?

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    the inline-block property on the

  5. tags was adding a space when rendering the nav-menu-template in Firefox 21.0.
  6. I've worked a lot with inline lists and I always use Firefox. But I don't think I have ever come across such an issue whose roots didn't like in the CSS.

Topic Closed

This topic has been closed to new replies.

About this Topic