JQuery + CSS achieve menu sliding and stretching (similar to Taobao)

Source: Internet
Author: User

The function is very practical and the code is very simple

Result 1.


Result 2.


The style code is as follows:

Copy codeThe Code is as follows: body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, br, pre, form, fieldset, input, textarea, p, blockquote, th, td {
Margin: 0;
Padding: 0
}
Span {
Color: # FF2B13
}
A {
Text-decoration: none;
Color: #515050.
}
A: hover {
Text-decoration: underline;
Color: red
}
. Box_all {
Overflow: hidden;
Width: 350px;
Font-family: "";
Font-size: 14px;
Border: 1px solid # EEEEEE;
Border-top: 2px solid # F57A04;
Padding: 0 0 10px 0;
Margin: 0 auto
}
. Box {
Padding-left: 45px;
Padding-top: 5px
}
. Box li {
Line-height: 20px;
Margin-right: 30px;
Width: 120px;
Text-align: left;
Float: left;
List-style-type: none
}
. Boxdown {
Cursor: pointer;
Border: 1px solid # EEEEEE;
Width: 60px;
Height: 14px;
Background: # FFFFFF url (../images/down.png) no-repeat 20px;
Margin-left: 150px;
Margin-top:-2px;
Border-top: none;
Margin: 0 auto
}
. Up {
Cursor: pointer;
Border: 1px solid # EEEEEE;
Width: 60px;
Height: 14px;
Background: # FFFFFF url (../images/up.png) no-repeat 20px;
Margin-left: 150px;
Margin-top:-2px;
Border-top: none;
Margin: 0 auto
}

The main JavaScript code is as follows:Copy codeThe Code is as follows: $ (document). ready (function (){
Var a = $ (". box ul li: gt (3): not (: last )");
A. hide ();
$ (". Boxdown"). click (function (){
If (a. is (': visible ')){
A. slideUp ('fast ');
$ (This). removeClass ('up ');
} Else {
A. slideDown ('fast '). show ();
$ (This). addClass ('up ');
}
});
});

Related Article

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.