Forums

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

Home Forums Design Add Submenu items – dropdown Reply To: Add Submenu items – dropdown

#234704
Chris Coyier
Keymaster

Looks like the list item that has the submenu has a class menu-item-has-childrenso you could write like…

.menu-item-has-children .sub-menu {
  /* hide this by default somehow maybe like this: */
  height: 0;
  overflow: hidden;
}

Then you’ll have to write some JavaScript to deal with opening it, something like…

$(".menu-item-has-children").on("click", function() {
  $(this).toggleClass("open-sub-menu");
});

in which this CSS would do the opening

.menu-item-has-children.open-sub-menu .sub-menu {
  height: auto;
}

There is lots more fancy things you could do, but that’ll get you started.