In times of responsive sites, the design of menus is a particular challenge. Especially for large and nested menus must be assured that they can be clearly displayed and save space on mobile devices. SmartMenus is a jQuery plugin for creating responsive and accessible menus based on one or more lists.
To build menus with Smart Menus for jQuery:
The HTML markup navigation menus is usually on the list elements “
- ” and “
- “. SmartMenus uses this approach, consequently, accordingly advance. It is also possible to use nested lists to generate submenus.
In addition to jQuery plug-in and a stylesheet file must be integrated so that SmartMenus works. Optionally, also the default theme (also a style sheet file) are activated. Thus, the menu gets directly an appropriate appearance. Alternatively, you can define individually their own stylesheets appearance.
This SmartMenus can generate from a list on the relevant menu, the list must be of class “sm” are assigned. If you want to use the default theme, you additionally sets the class “sm-blue”. And already is a responsive horizontal menu from the list. The plug-in provides four themes available. This can of course be used as a basis for a unique look.
Those who prefer the horizontal vertical menus, is also of SmartMenus served. About the additional classes “sm-vertical” and optionally “sm-blue-vertical” (for the included theme), the menu is displayed vertically.
This also runs everything, we still start the plug-in and apply it to the menu list:
$ ( function ( )
$ ( "# menu" ) . smart menus ( ) ;
Since the structure of the menu consists of simple lists, there is also readable for screen readers.
SmartMenus individually adapted:
Besides its own design of menus via style sheets there are numerous configuration options to affect the function of the menu. Thus, for example, the ability to control over the various jQuery methods, such as the sub-menus to be displayed. For this purpose, the “show function” option assigned to a corresponding method:
$ ( function ( )
$ ( "#menu" ) . smartmenus (
showFunction : function ( $liste , complete )
$liste. animate (
height : "toggle"
, complete ) ;
In the example, we use the “animate ()” method of jQuery to display submenus by animation. Alternatively, it is possible to use the “fadeIn ()” method of jQuery. Here is a great variety of jQuery options available.
With the “markCurrentItem” option is set if the currently requested page to be highlighted in the menu.
$ ( function ( )
$ ( "# menu" ) . smart menus (
markCurrentItem : 1
In this example, the option is enabled. The plug-in adds the respective link the class “current” time. Thus, it is then possible via style sheets to customize the appearance of the currently selected menu item. In addition to these offers SmartMenus several other parameters that may be where screwed. Feel free to experiment a little.
SmartMenus: License and Browser Support:
SmartMenus is under the MIT license and can therefore be used privately and commercially for free. In the future there will be premium rates, which include a support. But thanks to the detailed documentation to get even without premium support along well with the jQuery plugin.
SmartMenus supports all major browsers. Lo and behold, even the Internet Explorer version 6 does eagerly.