Responsive Drop Down Menu Plugin with jQuery

Responsive Drop Down Menu Plugin with jQuery
File Size: 554 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Yet another jQuery responsive menu plugin used to create a mobile-friendly, responsive, toggleable dropdown navigation for your cross-platform website. It utilizes CSS3 media queries to detect the screen size of devices browsing your website. Licensed under the GPLv3.

How to use it:

1.Apply Responsive Menu CSS.

<link href="dist/responsive-menu.css" rel="stylesheet">

2. Load jQuery library and the Responsive Menu plugin.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="dist/responsive-menu.js"></script>

3. Load modernizr.js or html5shiv.

<script src="http://cdn.jsdelivr.net/modernizr/2.8.3/modernizr.min.js"></script>
<!--<script src="//oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>-->

4. Create a regular navigation from a nested nav list.

<nav class="rm-nav rm-nojs rm-lighten">
  <ul>
    <li><a href="#">Main Item 1</a>
      <ul>
        <li><a href="#">Sub Item 1</a></li>
        <li><a href="#">Sub Item 2</a></li>
        <li><a href="#">Sub Item 3</a>
          <ul>
            <li><a href="#">Sub Sub Item 1</a></li>
            <li><a href="#">Sub Sub Item 2</a></li>
            <li><a href="#">Sub Sub Item 3</a></li>
            <li><a href="#">Sub Sub Item 4</a></li>
            <li><a href="#">Sub Sub Item 5</a></li>
            <li><a href="#">Sub Sub Item 6</a></li>
            <li><a href="#">Sub Sub Item 7</a></li>
          </ul>
        </li>
        <li><a href="#">Sub Item 4</a></li>
        <li><a href="#">Sub Item 5</a></li>
        <li><a href="#">Sub Item 6</a>
          <ul>
            <li><a href="#">Sub Sub Item 1</a></li>
            <li><a href="#">Sub Sub Item 2</a></li>
            <li><a href="#">Sub Sub Item 3</a></li>
            <li><a href="#">Sub Sub Item 4</a></li>
            <li><a href="#">Sub Sub Item 5</a></li>
            <li><a href="#">Sub Sub Item 6</a></li>
            <li><a href="#">Sub Sub Item 7</a></li>
          </ul>
        </li>
        <li><a href="#">Sub Item 7</a></li>
        <li><a href="#">Sub Item 8</a></li>
        <li><a href="#">Sub Item 9</a></li>
      </ul>
    </li>
    <li><a href="#">Main Item 2</a>
      <ul>
        <li><a href="#">Sub Item 1</a></li>
        <li><a href="#">Sub Item 2</a></li>
        <li><a href="#">Sub Item 3</a>
          <ul>
            <li><a href="#">Sub Sub Item 1</a></li>
            <li><a href="#">Sub Sub Item 2</a></li>
            <li><a href="#">Sub Sub Item 3</a></li>
            <li><a href="#">Sub Sub Item 4</a></li>
            <li><a href="#">Sub Sub Item 5</a></li>
            <li><a href="#">Sub Sub Item 6</a></li>
            <li><a href="#">Sub Sub Item 7</a></li>
          </ul>
        </li>
        <li><a href="#">Sub Item 4</a></li>
        <li><a href="#">Sub Item 5</a></li>
      </ul>
    </li>
    <li><a href="#">Main Item 3</a>
      <ul>
        <li><a href="#">Sub Item 1</a></li>
        <li><a href="#">Sub Item 2</a></li>
        <li><a href="#">Sub Item 3</a></li>
        <li><a href="#">Sub Item 4</a></li>
      </ul>
    </li>
    <li><a href="#">Main Item 4</a></li>
    <li><a href="#">Main Item 5</a>
      <ul>
        <li><a href="#">Sub Item 1</a></li>
        <li><a href="#">Sub Item 2</a></li>
      </ul>
    </li>
  </ul>
</nav>

5. Create a link to toggle the responsive menu on mobile device.

<a class="rm-toggle rm-button rm-nojs" href="#">Menu</a>

6. Call the plugin to enable the responsive menu.

$('.rm-nav').rMenu();

7. Full options.

/**
 * Minimum width for expanded layout in pixels - String Should match media query in css file
 * Must be in pixels and include px units if not using Modernizr.
 * @default '769px'
 */
minWidth: '769px',

/**
 * The opening and closing speed of the menus in milliseconds
 * @default 400
 */
transitionSpeed: 400,

/**
 * The jQuery easing function - used with jQuery transitions
 * @default 'swing'
 * @options 'swing', 'linear'
 */
jqueryEasing: 'swing',

/**
 * The CSS3 transitions easing function - used with CSS3 transitions
 * @default 'ease'
 */
css3Easing: 'ease',

/**
 * Use button as Toggle Link - instead of text
 * @default true
 */
toggleBtnBool: true,

/**
 * The Toggle Link selector
 * @default '.rm-toggle'
 */
toggleSel: '.rm-toggle',

/**
 * The menu/sub-menu selector
 * @default 'ul'
 */
menuSel: 'ul',

/**
 * The menu items selector
 * @default 'li'
 */
menuItemsSel: 'li',

/**
 * The class the plugin adds to the container of the nav element
 * @default 'rm-container'
 */
containerClass: 'rm-container',

/**
 * The class the plugin adds to the nav element
 * @default 'rm-nav'
 */
navElementClass: 'rm-nav',

/**
 * The class the plugin adds to the top menu element
 * @default 'rm-top-menu'
 */
topMenuClass: 'rm-top-menu',

/**
 * The class applied to menu items that contain a sub-menu
 * @default 'rm-parent'
 */
parentClass: 'rm-parent',

/**
 * The class applied to container element to trigger expanded layout
 * @default 'rm-layout-expanded'
 */
expandedClass: 'rm-layout-expanded',

/**
 * The class applied to container element to trigger contracted layout
 * @default 'rm-layout-contracted'
 */
contractedClass: 'rm-layout-contracted',

/**
 * Use CSS3 animation/transitions class name
 * @default 'rm-css-animate'
 * Do not use animation/transitions: ''
 */
animateClass: 'rm-css-animate',

/**
 * Force GPU Acceleration class name
 * @default 'rm-accelerate'
 * Do not force: ''
 */
accelerateClass: 'rm-accelerate',

/**
 * Use development mode - outputs information to console
 * @default false
 */
developmentMode: false

Change logs:

2015-06-15

  • v0.2.1

2015-05-31

  • v0.1.8

2015-05-08

  • v0.1.7

2015-04-14

  • v0.1.6

This awesome jQuery plugin is developed by jbowyers. For more Advanced Usages, please check the demo page or visit the official website.