JS+CSS简洁的二级下拉菜单代码,经测试,兼容性不错,推荐大家参考学习。如果您想实际运用到自己的网站中,可能要进行一些修改,比如CSS字体大小和颜色等,当然这需要您有一定的HTML知识。 示例: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>css二级菜单演示</title> <style type="text/css"> <!-- * { margin:0; padding:0; border:0; } body { font-family: arial, 宋体, serif; font-size:12px; } #nav { line-height: 24px; list-style-type: none; background:#666; } #nav a { display: block; width: 80px; text-align:center; } #nav a:link { color:#666; text-decoration:none; } #nav a:visited { color:#666; text-decoration:none; } #nav a:hover { color:#FFF; text-decoration:none; font-weight:bold; } #nav li { float: left; width: 80px; background:#CCC; } #nav li a:hover { background:#999; } #nav li ul { line-height: 27px; list-style-type: none; text-align:left; left: -999em; width: 80px; position: absolute; } #nav li ul li { float: left; width: 80px; background: #F6F6F6; } #nav li ul a { display: block; width: 80px; text-align:center } #nav li ul a:link { color:#666; text-decoration:none; } #nav li ul a:visited { color:#666; text-decoration:none; } #nav li ul a:hover { color:#F3F3F3; text-decoration:none; font-weight:normal; background:#C00; } #nav li:hover ul { left: auto; } #nav li.sfhover ul { left: auto; } #content { clear: left; } --> </style> <script type=text/javascript><!--//--><![CDATA[//><!-- function menuFix() { var sfEls = document.getElementById("nav").getElementsByTagName("li"); for (var i=0; i<sfEls.length; i++) { sfEls[i].onmouseover=function() { this.className+=(this.className.length>0? " ": "") + "sfhover"; } sfEls[i].onMouseDown=function() { this.className+=(this.className.length>0? " ": "") + "sfhover"; } sfEls[i].onMouseUp=function() { this.className+=(this.className.length>0? " ": "") + "sfhover"; } sfEls[i].onmouseout=function() { this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), ""); } } } window.onload=menuFix; //--><!]]></script> </head> <body> <ul id="nav"> <li><a href="#">新浪</a> <ul> <li><a href="#">新浪新闻</a></li> <li><a href="#">新浪体育</a></li> <li><a href="#">新浪汽车</a></li> <li><a href="#">新浪微博</a></li> <li><a href="#">新浪科技</a></li> </ul> </li> </ul> </body> </html><div style="text-align:center;margin:30px 0 0 0;"><hr style="color:#999;height:1px;">如不能显示效果,请按Ctrl+F5刷新本页,更多网页代码:<a href='http://www.veryhuo.com/' target='_blank'>http://www.veryhuo.com/</a></div>提示:可修改后代码再运行! 文章导航 JS简陋的下拉菜单代码,使用DW8制作的效果jQuery多级折叠(树形)菜单,动态展开和收缩