jquery CSS導航下拉式功能表代碼

來源:互聯網
上載者:User
 代碼如下 複製代碼

 

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html>
<head>
<title>伸縮的菜單,用toggle()重寫</title>
<style>
<!--
body{
background-color:#ffdee0;
}
#navigation {
width:200px;
font-family:arial;
}
#navigation > ul {
list-style-type:none; /* 不顯示項目符號 */
margin:0px;
padding:0px;
}
#navigation > ul > li {
border-bottom:1px solid #ed9f9f; /* 添加底線 */
}
#navigation > ul > li > a{
display:block; /* 區塊顯示 */
padding:5px 5px 5px 0.5em;
text-decoration:none;
border-left:12px solid #711515; /* 左邊的粗紅邊 */
border-right:1px solid #711515; /* 右側陰影 */
}
#navigation > ul > li > a:link, #navigation > ul > li > a:visited{
background-color:#c11136;
color:#ffffff;
}
#navigation > ul > li > a:hover{ /* 滑鼠經過時 */
background-color:#990020; /* 改變背景色 */
color:#ffff00; /* 改變文字顏色 */
}
/* 子功能表的css樣式 */
#navigation ul li ul{
list-style-type:none;
margin:0px;
padding:0px 0px 0px 0px;
}
#navigation ul li ul li{
border-top:1px solid #ed9f9f;
}
#navigation ul li ul li a{
display:block;
padding:3px 3px 3px 0.5em;
text-decoration:none;
border-left:28px solid #a71f1f;
border-right:1px solid #711515;
}
#navigation ul li ul li a:link, #navigation ul li ul li a:visited{
background-color:#e85070;
color:#ffffff;
}
#navigation ul li ul li a:hover{
background-color:#c2425d;
color:#ffff00;
}
-->
</style>
<script language="網頁特效" src="jquery.min.js"></script>
<script language="javascript">
$(function(){
$("li").find("ul").prev().click(function(){
$(this).next().toggle();
});
$("li:has(ul)").find("ul").hide();
});
</script>
</head>
<body>
<div id="navigation">
<ul id="listul">
<li><a href="#">home</a></li>
<li><a href="#">news</a>
<ul>
<li><a href="#">lastest news</a></li>
<li><a href="#">all news</a></li>
</ul>
</li>
<li><a href="#">sports</a>
<ul>
<li><a href="#">basketball</a></li>
<li><a href="#">football</a></li>
<li><a href="#">volleyball</a></li>
</ul>
</li>
<li><a href="#">weather</a>
<ul>
<li><a href="#">today's weather</a></li>
<li><a href="#">forecast</a></li>
</ul>
</li>
<li><a href="#">contact me</a></li>
</ul>
</div>
</body>
</html>

 

 

相關文章

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.