水平展开菜单,侧拉菜单
js菜单
XML/HTML Code
- <ul id="nav">
- <li><a href="http://www.freejs.net">首页</a></li>
- <li><a href="http://www.freejs.net">web代码演示</a>
- <ul>
- <li><a href="http://www.freejs.net/daohangcaidan.html" title="各种下拉菜单,导航,多级菜单,右侧展开,左侧展开">导航菜单</a></li>
- <li><a href="http://www.freejs.net/tabbiaoqian.html" title="tab标签,选项卡,选卡">TAB标签</a></li>
- <li><a href="http://www.freejs.net/jiaodiantu.html" title="焦点图,相册,幻灯片">焦点图</a></li>
- <li><a href="http://www.freejs.net/fenye.html" title="翻页,分页
- 本站演示中的分页数据库结构都一样的">分页</a></li>
- <li><a href="http://www.freejs.net/biaodan.html" title="表单">表单</a></li>
- <li><a href="http://www.freejs.net/jquerytupiantexiao.html" title="Jquery图片特效">Jquery图片</a></li>
- <li><a href="http://www.freejs.net/jquerywenzi.html" title="jquery文字特效,js文字特效">Jquery文字</a></li>
- </ul>
- </li>
- <li><a href="#">服务</a>
- <ul>
- <li><a href="#">Web Design</a></li>
- <li><a href="#">Internet Marketing</a></li>
- <li><a href="#">Hosting</a></li>
- <li><a href="#">Domain Names</a></li>
- <li><a href="#">Broadband</a></li>
- </ul>
- </li>
- </ul>
css文件
CSS Code
- body {
- font: normal 11px verdana;
- }
- ul {
- margin: 0;
- padding: 0;
- list-style: none;
- width: 150px; /* Width of Menu Items */
- border-bottom: 1px solid #ccc;
- }
- ul li {
- position: relative;
- }
- li ul {
- position: absolute;
- left: 149px; /* Set 1px less than menu width */
- top: 0;
- display: none;
- }
- /* Styles for Menu Items */
- ul li a {
- display: block;
- text-decoration: none;
- color: #777;
- background: #fff; /* IE6 Bug */
- padding: 5px;
- border: 1px solid #ccc; /* IE6 Bug */
- border-bottom: 0;
- }
- /* Holly Hack. IE Requirement */
- * html ul li { float: left; height: 1%; }
- * html ul li a { height: 1%; }
- /* End */
- li:hover ul, li.over ul { display: block; } /* The magic */
JS文件
JavaScript Code
- // JavaScript Document
- startList = function() {
- if (document.all&&document.getElementById) {
- navRoot = document.getElementById("nav");
- for (i=0; i<navRoot.childNodes.length; i++) {
- node = navRoot.childNodes[i];
- if (node.nodeName=="LI") {
- node.onmouseover=function() {
- this.className+=" over";
- }
- node.onmouseout=function() {
- this.className=this.className.replace(" over", "");
- }
- }
- }
- }
- }
- window.onload=startList;
原文地址:http://www.freejs.net/article_daohangcaidan_36.html