Templates: 1 2 3 4 5

DdMenu: Mega Dropdown Menu

Features

HTML

Full code
<nav id="ddmenu">
    <div class="menu-icon"></div>
    <ul>
        <li>...</li>
        ... ...
        <li>...</li>
    </ul>
</nav>
  1. Add <li class="no-sub"> if there is no dropdown sub-menu under the <li> element;
  2. Add <li class="full-width"> if you want the dropdown to have the same width of the menu (100% width of its parent UL element).
  3. To hide an element on mobile (but not on desktop), add class="may-hide" to that element in the dropdown.

CSS

The CSS file is provided in the download package.

JavaScript

Open ddmenu.js from the download package and configure the options as needed:

var ddmenuOptions=
{
    menuId: "ddmenu",
    linkIdToMenuHtml: null,
    open: "onmouseover",  //or "onclick"
    delay: 90,
    speed: 400,
    keysNav: true,
    singleOpen: false,
};

var ddmenu = new Ddmenu(ddmenuOptions);
linkIdToMenuHtml:  null by default. If you want to store your website menu in a separate file so that you do not need to cut and paste the menu HTML code on every page, you can assign linkIdToMenuHtml with a link ID that links to the separate menu file. Please refer to One Menu for All Pages for details.

Animation speed (in milliseconds) of the dropdown sub-menu.

Note: The transition speed for the background color of top-level menu items (<li>) is defined in the ddmenu.css:

#ddmenu li { transition:background-color 0.2s; }

Using TAB or arrow keys to navigate through the mega menu links.

Set it to false will disable this accessibility.

When the menu is displayed vertically on mobile devices and SingleOpen: true is set, opening one menu item will automatically close any other open menu items.

Thanks for using Menucool DdMenu

The download package contains the source code and all five templates.

Confirm Download

Dynamic Menu Creation

ddmenu initializes when the page loads. If the menu markup is added later, initialize ddmenu using one of two methods: