I recently studied JQuery and tried to create this navigation.
Download: Code
Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> scaling navigation </title>
<Link rel = "stylesheet" type = "text/css" href = "nav.css">
<Script type = "text/javascript" src = "jquery-1.10.2.js"> </script>
<Script type = "text/javascript" src = "nav. js"> </script>
</Head>
<Body>
<Div class = "navigator">
<Ul class = "tabs">
<Li class = "tab1">
<H3> navigation Card 1 <Ul class = "nav1">
<Li> subproject 1 </li>
<Li> subproject 2 </li>
<Li> sub-project 3 </li>
<Li> sub-project 4 </li>
</Ul>
</Li>
<Li class = "tab2">
<H3> navigation Card 2 <Ul class = "nav2">
<Li> subproject 1 </li>
<Li> subproject 2 </li>
<Li> sub-project 3 </li>
<Li> sub-project 4 </li>
</Ul>
</Li>
<Li class = "tab3">
<H3> navigation card 3 <Ul class = "nav3">
<Li> subproject 1 </li>
<Li> subproject 2 </li>
<Li> sub-project 3 </li>
<Li> sub-project 4 </li>
</Ul>
</Li>
</Ul>
</Div>
</Body>
</Html>
Copy codeThe Code is as follows:
/**
* Author LY
**/
*{
Margin: 0;
Padding: 0;
Font-family: "Microsoft Yahei", "Arial"
}
. Navigator {
Width: 180px;
Display: block;
Margin-top: 30px;
Margin-left: 30px;
Border-top: 10px solid # ddd;
Border-bottom: 10px solid # ddd;
Border-left: 3px solid # ddd;
Border-right: 3px solid # ddd;
Background: # ddd;
}
. Tabs {
List-style: none;
}
. Tabs li {
Clear: both;
Overflow: auto;
}
. Tabs li h3 {
Padding: 0;
Margin: 0;
Font-size: 14px;
Height: 40px;
Line-height: 40px;
Text-align: center;
Width: 180px;
Cursor: pointer;
Background: # 07f;
Color: # fff;
Border-bottom: 1px solid # ccc;
}
. Tabs li: last-child h3 {
Border: none;
}
. Tabs li h3.current {
Background: # 6af;
}
. Tabs li ul {
Margin-left: auto;
Margin-right: auto;
Width: 160px;
Height: 0px;
List-style: none;
Overflow: hidden;
}
. Tabs li ul li {
Height: 30px;
Line-height: 30px;
Background: # eee;
Padding: 5px;
Border-bottom: 1px solid # ccc;
Cursor: pointer;
}
Copy codeThe Code is as follows:
$ (Document). ready (function (){
$ (". Nav1" ).css ("height", "160px ");
$ (". Tabs li h3: first"). addClass ("current ");
$ (". Tabs li h3"). click (function (){
$ (". Tabs li h3"). removeClass ("current ");
$ (This). addClass ("current ");
$ (". Tabs li ul"). animate ({height: "0"}, "fast ");
$ (This). next (). animate ({height: "160"}, "slow ");
});
});