A jquery-based animation navigation menu

Source: Internet
Author: User

A jquery-based animation navigation menu

Today, I will share with you a jquery-based animation navigation menu. This navigation menu, a button in the middle of the page, click the button, the menu from the left navigation page. Click the button again to navigate to the left-side message. The animation effect is very dazzling. Let's take a look:

Download Online Preview source code

Implementation code.

Html code:

 <ul>        <li><a href="http://www.w2bc.com">First</a></li>        <li><a href="http://www.w2bc.com">Second</a></li>        <li><a href="http://www.w2bc.com">Third</a></li>        <li><a href="http://www.w2bc.com">Fourth</a></li>        <li><a href="http://www.w2bc.com">Fifth</a></li>    </ul>    <button>        Animate</button>    <script src='jquery.js'></script>    <script>        $('button').on('click', function () {            $('ul').toggleClass('animate');        }); //@ sourceURL=pen.js    </script>

Css code:

 body        {            text-align: center;        }                ul        {            width: 400px;            padding: 0;            margin: 0 auto;        }        ul.animate li        {            transform: translate(0);        }        ul.animate li:nth-of-type(1)        {            transition-delay: 0.05s;        }        ul.animate li:nth-of-type(2)        {            transition-delay: 0.1s;        }        ul.animate li:nth-of-type(3)        {            transition-delay: 0.15s;        }        ul.animate li:nth-of-type(4)        {            transition-delay: 0.2s;        }        ul.animate li:nth-of-type(5)        {            transition-delay: 0.25s;        }                li        {            list-style: none;            display: block;            padding: 20px;            margin: 12px 0;            border-radius: 5px;            font-family: Helvetica, sans-serif;            color: #fff;            background: #8DE48D;            transform: translate(-500%);            transition: transform 0.75s cubic-bezier(0.175, 0.885, 0.32, 1.08);        }        li:nth-of-type(5)        {            transition-delay: 0.15s;        }        li:nth-of-type(4)        {            transition-delay: 0.3s;        }        li:nth-of-type(3)        {            transition-delay: 0.45s;        }        li:nth-of-type(2)        {            transition-delay: 0.6s;        }        li:nth-of-type(1)        {            transition-delay: 0.75s;        }                button        {            padding: 12px 18px;            border: none;            border-radius: 3px;            color: #fff;            background: #7DBED8;        }        button:focus        {            outline: none;        }

Note: This article love programming Original article, reprint please indicate the original address: http://www.w2bc.com/Article/9693


How does jquery control the navigation menu of the current page?

For example, the <div class = "nav"> <a href = "index.html"> homepage </a> <a href = "product.html"> product </a>
The following html content:
<Div class = "main">
<Div class = "content"> homepage content </div>
<Div class = "content"> product content </div>
<Div class = "content"> case center content </div>
</Div>
As for class = "content", you can add it yourself to facilitate jQuery's acquisition, without this style class.
<Script type = "text/javascript">
$ (Document). ready (function ()
{
Var tabs =$ ('. nav> ');
Var cons = $ ('. main> div. content ');

Tabs. first (). addClass ("now"). show (); // The first display by default
Cons. first (). show (). nextAll (). hide (); // The first display is displayed by default, and others are hidden.
Tabs. each (function (index ){
$ (This). mouseover (function (){
$ (This). addClass ("now"). siblings (). removeClass ("now ");
Cons. eq (index). show (). siblings (). hide ();
});
});

});
</Script>

When I click in the navigation bar made by jquery, all the level-2 menus are displayed. How can I show only one menu?

I suggest you add a name for each option on the list to be clicked. The name is the same as the actual list class name.
<Li name = "tr"> Home </li>
<Li name = "tr1"> homepage 2 </li>
<Li name = "tr2"> homepage 3 </li>
<Li name = "tr3"> homepage 4 </li>
<Li name = "tr4"> Home Page 5 </li>
<Li name = "tr5"> homepage 6 </li>
<Li name = "tr6"> homepage 7 </li>
<Li name = "tr7"> homepage 8 </li>

Then jquery
$ (Document). ready (function (){

$ ('# Td li'). click (function (){
$ ("# Men." + $ (this). attr ("name" )).css ("display", "inline ");
});
});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.