Taming the Desktop Mega Menu: A Shopify Horizon Theme Fix for Clean Dropdowns

Hey everyone! It's always great to dive into the Shopify Community forums and see store owners helping each other tackle those little design tweaks that make a huge difference. Recently, I stumbled upon a fantastic discussion that really resonated with a common challenge: perfecting your desktop main menu. Our fellow store owner, veluxe1, brought up a super common pain point, especially for those running the Horizon theme: how to rein in those sprawling, full-width mega menu dropdowns on desktop and make them look, well, cleaner.

The Full-Width Menu Dilemma

Veluxe1's dilemma was pretty clear: on desktop, their mega menu dropdowns were spanning the entire width of the page. While this can work for some designs, many of us prefer a more compact, card-like dropdown that aligns neatly under its parent menu item. Not only does it look more professional, but it also improves the user experience by keeping related content visually grouped. The initial screenshot veluxe1 shared really highlighted this – a beautiful store, but with a menu that felt a little out of bounds.

Initial Attempts and Why They Fell Short

As is often the case in community discussions, several helpful members jumped in. Steve_TopNewYork and topnewyork offered some initial CSS snippets, suggesting max-width and margin: 0 auto to center the menu. While these are good general approaches for centering blocks, veluxe1 quickly pointed out that it "seemed like nothing changed" or that the menu was still centered when they wanted it aligned to the left, under the specific menu item it belonged to. This is where the nuances of CSS and theme-specific structures come into play. It's not just about shrinking; it's about anchoring and positioning correctly.

The Breakthrough: AjayCodeWiz's Expert Insight

This is where AjayCodeWiz stepped in with a brilliant diagnosis. After "installing the Horizon theme (guessed in your site’s source code)" and reproducing the problem, they identified the core issue: the Horizon theme's submenu panel (.menu-list__submenu) by default was set to position: absolute; width: 100%; left: 0. This is precisely why it was spanning the whole page!

AjayCodeWiz's solution was elegant because it didn't just try to center a full-width element; it fundamentally changed how the dropdown behaved, turning it into a compact, item-aligned card. Here's a look at the "after" picture that AjayCodeWiz shared – exactly what veluxe1 was looking for:

Step-by-Step Instructions to Implement the Fix

If you're facing a similar issue with your desktop mega menu, especially if you're on the Horizon theme, here's how you can implement AjayCodeWiz's fix. Remember, always back up your theme before making any code changes!

How to Implement the Compact Desktop Mega-Menu Dropdown Fix:

  1. Access Your Theme Code:
    • From your Shopify admin, go to Online StoreThemes.
    • Find the theme you want to edit (ideally, a duplicate of your live theme).
    • Click ActionsEdit code.
  2. Locate the CSS File:
    • In the left sidebar, navigate to the Assets folder.
    • Look for a file named base.css or theme.css (base.css is the most common place for general CSS additions).
    • Click on the file to open it in the code editor.
  3. Add the CSS Code:
    • Scroll to the very bottom of the base.css file.
    • Paste the following code exactly as it appears:
    /* Compact desktop mega-menu dropdown (Horizon). Desktop only - mobile drawer untouched. */
    @media screen and (min-width: 990px) {
      /* anchor each dropdown to its own menu item */
      .menu-list__list-item { position: relative; }
    
      /* shrink the panel from full-width to a compact dropdown under the item */
      .menu-list__list-item:not([slot='overflow']) > .menu-list__submenu {
        width: max-content !important;
        max-width: min(90vw, 320px) !important;
        left: 0 !important;
        right: auto !important;
        top: 100% !important;
        padding-inline: 0 !important;
        clip-path: none !important;
      }
    
      /* size the content to itself and stack the links vertically */
      .menu-list__list-item:not([slot='overflow']) > .menu-list__submenu .mega-menu,
      .menu-list__list-item:not([slot='overflow']) > .menu-list__submenu .mega-menu__grid { width: 100% !important; }
      .menu-list__list-item:not([slot='overflow']) > .menu-list__submenu .mega-menu__grid { display: block !important; }
      .menu-list__list-item:not([slot='overflow']) > .menu-list__submenu .mega-menu__link { display: block !important; }
    
      /* give it a proper dropdown-card look */
      .menu-list__list-item:not([slot='overflow']) > .menu-list__submenu .menu-list__submenu-inner {
        transform: none !important;
        padding: 14px 22px !important;
        background: var(--color-background, #fff);
        border: 1px solid rgb(var(--color-foreground-rgb) / 0.08);
        border-radius: 10px;
        box-shadow: 0 10px 30px rgb(var(--color-foreground-rgb) / 0.14);
      }
    }
    
  4. Understand the Code (Optional, but helpful!):
    • @media screen and (min-width: 990px): This ensures the changes only apply on desktop screens (990px and wider), leaving your mobile menu untouched.
    • .menu-list__list-item { position: relative; }: This is key! It makes the parent menu item the reference point for positioning its dropdown, allowing the dropdown to align directly underneath it.
    • .menu-list__list-item:not([slot='overflow']) > .menu-list__submenu { ... }: This targets the actual dropdown panel.
      • width: max-content !important; max-width: min(90vw, 320px) !important;: This shrinks the dropdown to fit its content, but also limits it to a maximum of 320px (or 90% of the viewport width if smaller). You can adjust 320px to your preferred width.
      • left: 0 !important; right: auto !important; top: 100% !important;: These properties position the dropdown precisely at the left edge and directly below its parent menu item.
    • The subsequent rules (.mega-menu, .mega-menu__grid, .mega-menu__link) ensure the content within the dropdown also adapts to the new, narrower layout, stacking links vertically and occupying 100% of the dropdown's new width.
    • The final block styles the dropdown as a "card," adding padding, a background, a border, and a subtle box-shadow for a modern, clean look. It even uses CSS variables like var(--color-background, #fff) for better theme integration, pulling colors from your theme settings.
  5. Save and Test:
    • Click the Save button in the top right corner.
    • Visit your online store and test your desktop menu to ensure the dropdowns are now compact and aligned as desired.

It’s fantastic to see how a little bit of community collaboration and a keen eye for theme structure can solve what seems like a complex design problem. This discussion really highlights the power of digging into your theme's CSS and understanding how elements are positioned. Whether you're just starting your journey on Shopify or you're a seasoned pro looking to refine your store's aesthetics, remember that the details in your navigation can significantly impact how customers experience your brand. And if you're ever thinking about starting your own amazing store, remember how flexible and powerful the platform is – you can start building your dream business with Shopify and customize it to perfection, just like veluxe1 did here! Keep those questions coming in the forums, and let's keep learning together.

Share:

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools