<strong>方式一:直接编写代码实现</strong> <br>效果如下: <br><img src="http://files.jb51.net/upload/201008/20100807165719894.gif" border="0" alt="纯CSS打造的导航菜单(附jquery版)_jquery" ><br>代码如下: <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="20953" class="copybut" id="copybut20953" onclick="doCopy('code20953')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code20953"> <br> <br> <br><title>无需表格的菜单</title> <br><style> <BR><!-- <BR>body{ <BR>background-color:#ffdee0; <BR>} <BR>#navigation { <BR>width:200px; <BR>font-family:Arial; <BR>} <BR>#navigation ul { <BR>list-style-type:none; /* 不显示项目符号 */ <BR>margin:0px; <BR>padding:0px; <BR>} <BR>#navigation li { <BR>border-bottom:1px solid #ED9F9F; /* 添加下划线 */ <BR>} <BR>#navigation li a{ <BR>display:block; /* 区块显示 */ <BR>padding:5px 5px 5px 0.5em; <BR>text-decoration:none; <BR>border-left:12px solid #711515; /* 左边的粗红边 */ <BR>border-right:1px solid #711515; /* 右侧阴影 */ <BR>width:175px; /* xg_超连接以外的部分也触发CSS样式效果 */ <BR>} <BR>#navigation li a:link, #navigation li a:visited{ <BR>background-color:#c11136; <BR>color:#FFFFFF; <BR>} <BR>#navigation li a:hover{ /* 鼠标经过时 */ <BR>background-color:#990020; /* 改变背景色 */ <BR>color:#ffff00; /* 改变文字颜色 */ <BR>} <BR>--> <BR></style> <br> <br> <br><div id="navigation"> <br><ul> <br><li><a href="#">Home</a></li> <br><li><a href="#">News</a></li> <br><li><a href="#">Sports</a></li> <br><li><a href="#">Weather</a></li> <br><li><a href="#">Contact Me</a></li> <br> </ul> <br> </div> <br> <br> <br> </div> <br><strong>方式二:使用jQuery 代码实现</strong> <br>代码如下: <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="12667" class="copybut" id="copybut12667" onclick="doCopy('code12667')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code12667"> <br> <br> <br> <br><title>伸缩的菜单,用toggle()重写</title> <br><style> <BR><!-- <BR>body{ <BR>background-color:#ffdee0; <BR>} <BR>#navigation { <BR>width:200px; <BR>font-family:Arial; <BR>} <BR>#navigation > ul { <BR>list-style-type:none; /* 不显示项目符号 */ <BR>margin:0px; <BR>padding:0px; <BR>} <BR>#navigation > ul > li { <BR>border-bottom:1px solid #ED9F9F; /* 添加下划线 */ <BR>} <BR>#navigation > ul > li > a{ <BR>display:block; /* 区块显示 */ <BR>padding:5px 5px 5px 0.5em; <BR>text-decoration:none; <BR>border-left:12px solid #711515; /* 左边的粗红边 */ <BR>border-right:1px solid #711515; /* 右侧阴影 */ <BR>} <BR>#navigation > ul > li > a:link, #navigation > ul > li > a:visited{ <BR>background-color:#c11136; <BR>color:#FFFFFF; <BR>} <BR>#navigation > ul > li > a:hover{ /* 鼠标经过时 */ <BR>background-color:#990020; /* 改变背景色 */ <BR>color:#ffff00; /* 改变文字颜色 */ <BR>} <BR>/* 子菜单的CSS样式 */ <BR>#navigation ul li ul{ <BR>list-style-type:none; <BR>margin:0px; <BR>padding:0px 0px 0px 0px; <BR>} <BR>#navigation ul li ul li{ <BR>border-top:1px solid #ED9F9F; <BR>} <BR>#navigation ul li ul li a{ <BR>display:block; <BR>padding:3px 3px 3px 0.5em; <BR>text-decoration:none; <BR>border-left:28px solid #a71f1f; <BR>border-right:1px solid #711515; <BR>} <BR>#navigation ul li ul li a:link, #navigation ul li ul li a:visited{ <BR>background-color:#e85070; <BR>color:#FFFFFF; <BR>} <BR>#navigation ul li ul li a:hover{ <BR>background-color:#c2425d; <BR>color:#ffff00; <BR>} <BR>--> <BR></style> <br><script language="javascript" src="jquery.min.js"></script> <br><script language="javascript"> <BR>$(function(){ <BR>$("li").find("ul").prev().click(function(){ <BR>$(this).next().toggle(); <BR>}); <BR>$("li:has(ul)").find("ul").hide(); <BR>}); <BR></script> <br> <br> <br><div id="navigation"> <br><ul id="listUL"> <br><li><a href="#">Home</a></li> <br><li> <a href="#">News</a> <br><ul> <br><li><a href="#">Lastest News</a></li> <br><li><a href="#">All News</a></li> <br> </ul> <br> </li> <br><li> <a href="#">Sports</a> <br><ul> <br><li><a href="#">Basketball</a></li> <br><li><a href="#">Football</a></li> <br><li><a href="#">Volleyball</a></li> <br> </ul> <br> </li> <br><li> <a href="#">Weather</a> <br><ul> <br><li><a href="#">Today's Weather</a></li> <br><li><a href="#">Forecast</a></li> <br> </ul> <br> </li> <br><li><a href="#">Contact Me</a></li> <br> </ul> <br> </div> <br> <br> <br> </div> <br>注意:该代码必须加载了jquery.min.js 文件,并且所写的CSS 只能在Firefox 浏览器中正常显示。