Hybrid Collapsible Menu For Email

Update Oct 2016: With the recent Gmail update, the code was edited to prevent the menu from showing in Gmail apps (which does not support interactivity).

There has been a lot of interest in mobile menus in email ever since Jerry Martinez came out with his hamburger collapsible menu. The technique required the use of a checkbox to trigger the display and hiding of the menu.

However, a limitation of using checkboxes is that certain email service providers namely MailChimp does not support form elements in email and will strip them when the email is sent. In the same vein, some modern mobile email clients, namely Outlook on iOS does not support form elements as well.

Here’s a collapsible navigation menu for email that uses the :checked selector when available and :hover when not.

hamburger-hybrid


Hover

An alternative to using checkboxes is the use of the :hover selector. Hover has wide support on both email service providers and modern email clients. However, in certain cases the hover implementation on some clients are less reliable and glitchy than using a checkbox – particularly on the Windows 8.1 and Outlook for iOS clients.

Hybrid

Here’s a hybrid menu implementation that will use the checkbox mechanism when available, and fallback to hover when not. This way the code can be used on ESPs that don’t support form elements – though in that case, only the hover mechanism will be present in the email.

Specifically, the :hover selector below can only become active when .nav-over is a direct descendent of #navcontainer. In the original markup, .nav-over’s parent is a label, so by default, the :hover selector will not fire. However if the label is removed by the ESP or email client, then the :hover selector is enabled.



Code

View a live example here.

Here’s the code:
(Note -webkit-min-device-pixel-ratio was added to the media query filter to prevent it from appearing in Gmail after the updates)



Feedback

I’d love to hear your experiements with navigation menus and what other quirks you have encountered while using them.





Subscribe to the #EmailGeeks Newsletter


Latest Comments
  1. Jeff

    Awesome, thanks for this!

  2. Tony

    The collapsible menu works fine in IOS, but I noticed that there’s extra spacing between the menu bar and the content following when viewing it on an Android device. Not sure why that is, your thoughts?

  3. Marjolein

    Thanks for the code!
    I did another update to remove the navigation in Gmail/Inbox altogether (because my clients always want way too many items in their navigation – it would push apart the mail in Gmail).

    So I used the update seen in the EmailonAcid webinar about Gmail updates and added:

    u + .body #navcontainer {
    display: none !important;
    }

    (gave the body tag a class = body)

  4. Marjolein

    It seems the Outlook.com app has received an update that now breaks this code. Even with the media query set to webkit only (@media (max-width:480px) and (-webkit-min-device-pixel-ratio: 0)) it shows both the hamburger images AND a dropped down navigation. I can live with the navigation shown completely I guess, but any idea how to hide the hamburger images?

    I’m testing on an Android, but know it’s also an issue on iOS.

    • Jaemi

      You could remove the nav-over div, and then you’ll only see one set of lines in Outlook on mobile. You’d have to test to make sure it didn’t break anything anywhere else you care about, but from my preliminary testing, it didn’t break the menu. Frustrating. Outlook mobile considers itself webkit. So you can’t really hide from it without losing the whole thing. But if it’s webkit, it ought to work….

Leave a Reply

Your email address will not be published. Required fields are marked *