十二、下拉及多级弹出菜单(超简捷代码)

以下为下拉式多级菜单样式实现:
已测试好,欢迎下载使用,这是我见过的最简捷的代码!

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>下拉多级菜单-css系列教程-超级宝贝-http://www.chaojibaby.com</title>
<script type="text/Javascript"><!--//--><![CDATA[//><!--
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;    
    
//--><!]]></script>
<style>
ul { padding:
0; margin:0; list-style:none;}
li { float:
left; width:100px;}
ul li a { display:block; font
-size:12px; border:1px solid #ccc; margin-top:2px; margin-left:3px; padding:3px; text-decoration:none; color:#777;}
ul li a:hover { background
-color:#ddd;}
li ul { display:none; top:20px;}
li:hover ul,li.over ul { display:block;}
</style>

</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>
        
</ul>
    
</li>
    
<li><a href="#">程序</a>
        
<ul>
            
<li><a href="#">asp程序</a></li>
            
<li><a href="#">php程序</a></li>
            
<li><a href="#">jsp程序</a></li>
        
</ul>
    
</li>
    
<li><a href="#">维护</a>
        
<ul>
            
<li><a href="#">网站编辑</a></li>
            
<li><a href="#">网站推广</a></li>
            
<li><a href="#">网站优化</a></li>
        
</ul>
    
</li>
</ul>
</body>
</html>

效果如图

posted @ 2008-08-16 13:15  ike_li  阅读(303)  评论(0)    收藏  举报