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

Home Forums CSS [Solved] Make this horizontal drop-down menu stretch the width of the screen?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #177687

    Hello! I’m attempting to make a full-width, CSS drop-down menu, where the sub-menu ‘ul’ items are offset slightly to the left of their parent.

    Here’s the goal, from my designer:

    And what I’ve made, so far:

    I’ve run into two problems:

    1. I have to set a width on my sub-menu ul (in the CodePen link below, 200px), as it doesn’t stretch to fit the ‘li’ elements within, and;
    2. I’m stumped when it comes to making the sub-menu stretch to fill the width of the screen, as in the designer’s image.

    Here it is on CodePen:

    Thanks! Love this forum.


    I’m sure I’m missing something…this should be easy but I’m having trouble with it.

    Giving the submenu an absolute position and centering the internal list items under the parent li is tricky.


    @Soronbe: It’s like magic!

    I see you added ‘margin: 0 -9999px; padding: 0 9999px;’ to .main-navigation ul li:hover > ul

    Everything works great on CodePen, but on my development site the li items in the sub-menu are vertical, not horizontal. The sub-menu ul seems to be taking its width from the parent li.

    Here’s a screenshot.

    I’ve tried to see if other CSS on the site is affecting it, but no dice yet.


    Sorry: The development site is running on a localhost, so I have no link to send!

    BUT: @Atelierbram’s implementation of @Soronbe’s idea (link) is almost there.

    It seems the box-sizing: inherit in the reset is fixing the problem with the vertical/horizontal resizing, though it’s had the unintended consequence of pushing the menu up to the top of the page.

    Screens: no hover / hover

    Here’s a revised pen that includes my entire stylesheet:


    @Atelierbram Aha. WordPress automatically outputs that code so I had to figure out how to get rid of it. Done.

    The menu works! Amazing.

    BUT: The * {box-sizing:inherit} is somehow screwing up formatting on a few other parts of the site. (I see my CSS, which is pulled from has a box-sizing: border-box reset.)

    Is there a way to isolate your reset so it applies only to the nav menu, or should I re-adjust the rest of the site to compensate for the change?

    (Apologies: I don’t know a lot about border-box)


    You’re a genius! Thank you.

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