一个简单操作的menu.js 菜单
Menu.js is a free, small JavaScript (drop-down) menu for developers. It's unobtrusive and only requires a HTML unordered list and your own CSS styles.
下載:http://www.menujs.net/downloads/Menu.js-1.3.1.zip
例子:
Example.html
01020304050607080910111213141516171819202122232425262728293031323334353637383940414243444546474849 <html> <head> <script type="text/javascript" src="script/Menu.js"> </script> <script type="text/javascript"> //用法:Menu.init('ID',{'option'}) Menu.init("menu", {"orientation": Menu.HORIZONTAL, "hidePause": 0.5,"opacity":0.5}); /* Option有4個 orientation (int; one of: Menu.HORIZONTAL, Menu.VERTICAL) HORIZONTAL-水平顯示下拉菜单/VERTICAL-垂直顯示下拉菜單 showPause (float; in seconds; default: 0.0) 按下選項後的延迟時間,預設為0秒 hidePause (float; in seconds; default: 1.0 ) 離開選項後的延迟時間,預設為1秒 opacity (float; 0 = transparent, 1 = opaque; default: 1) 透明度,預設為1,即不透明 */ </script> <link rel="stylesheet" type="text/css" href="css/Style-HORIZONTAL.css" /> </head> <body> <ul id="menu"> <li><a href="/index.html">Home</a></li> <li><a href="/about.html">About</a></li> <li><a href="/technology.html">Technologies</a> <ul> <li><a href="/markup.html">Markup</a> <ul> <li><a href="/markup_html.html">HTML</a></li> <li><a href="/markup_xhtml.html">XHTML</a></li> <li><a href="/markup_xml.html">XML</a></li> </ul> </li> <li><a href="/css.html">CSS</a></li> <li><a href="/javascript.html">JavaScript</a></li> <li><a href="/prototype.html">Prototype JS</a></li> </ul> </li> <li><a href="/contact.html">Contact</a></li> </ul> </body> </html>
Style-HORIZONTAL.css
#menu,
#menu ul { margin: 0; padding: 0; }
010203040506070809101112131415161718 #menu li { list-style-type: none; } /* 第一層次 */#menu li, #menu a { float: left; width: 100px; } #menu a { display: block; background: #EEE; } #menu a:hover, #menu a.menu_open { background: #DDD; } /* 第二層次 */#menu ul { visibility: hidden; position: absolute; width: 100px; } #menu ul a { background: #DDD; } #menu ul a:hover, #menu ul a.menu_open { background: #CCC; } /* 第三層次(顏色) */#menu ul ul a { background: #CCC; } #menu ul ul a:hover { background: #BBB; }
Style-VERTICAL.CSS
010203040506070809101112131415161718192021 #menu, #menu ul { margin: 0; padding: 0; } #menu li { list-style-type: none; } /* 第一層*/#menu { width: 100px; } #menu li, #menu a { float: left; width: 100px; } #menu a { display: block; background: #EEE; } #menu a:hover, #menu a.menu_open { background: #DDD; } /* 第二層 */#menu ul { visibility: hidden; position: absolute; width: 100px; } #menu ul a { background: #DDD; } #menu ul a:hover, #menu ul a.menu_open { background: #CCC; } /* 第三層(顏色) */#menu ul ul a { background: #CCC; } #menu ul ul a:hover { background: #BBB; }