Giter Club home page Giter Club logo

simple-mobile-nav's Introduction

Simple Mobile Nav (plugin jQuery)

Make a simple nav with list item suitable for small devices

Live Demo

Given the following markup:

<nav role="navigation">
  <span>Title</span>
  <ul>
    <li><a href="#">Link</a></li>
    <li><a href="#">Link</a>
      <ul>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
      </ul>
    </li>
    <li><a href="#">Link</a>
      <ul>
        <li><a href="#">Link</a>
          <ul>
            <li><a href="#">Link</a></li>
            <li><a href="#">Link</a></li>
            <li><a href="#">Link</a></li>
            <li><a href="#">Link</a></li>
            <li><a href="#">Link</a>
              <ul>
                <li><a href="#">Link</a></li>
                <li><a href="#">Link</a></li>
                <li><a href="#">Link</a></li>
                <li><a href="#">Link</a></li>
                <li><a href="#">Link</a></li>
              </ul>
            </li>
          </ul>
        </li>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
      </ul>
    </li>
    <li><a href="#">Link</a></li>
    <li><a href="#">Link</a></li>
  </ul>
</nav>

you can turn it into a mobile nav by inserting the script mobilenav.jquery.js after jQuery inclusion:

<script type="text/javascript" src="https://code.jquery.com/jquery-latest.min.js"></script>
<script src="mobilenav.jquery.js"></script>

and after that init the mobile nav, possibly at the DOM ready:

<script>
  $(document).ready( function () {

      $('nav[role="navigation"]').mobilenav();

  });
</script>

The nav accepts two config parameters:

  • sticky: false (default) | true stick the nav position to top while scrolling
  • mainCategoryLinked: true (default) | false if true every submenu will open by only clicking the + icon, if false the link will work all over the link item. Bear in mind that this will disallow menu item to be link to his refering page

The script already adds the class "mobile-nav" to the element on which is initializ, in the example nav[role="navigation"], but it is possible that you see the unformatted menu for a while if run on the onready event of the DOM. To solve this you can simply add the class on the element directly into the markup.

<nav role="navigation" class="mobile-nav">

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.