JS+CSS实现的二级下拉导航菜单
来源:广州中睿信息技术有限公司官网
发布时间:2012/10/21 23:25:16 编辑:admin 阅读 495
代码简介:CSS配合JavaScript实现二级下拉导航菜单,好像CSS要配合JS才能写出好效果来,本款菜单同样用到了Js哦,菜单目前支持两级,下拉导航是我们经常用的一种菜单形式,把这个修改一下你就

代码简介:

CSS配合JavaScript实现二级下拉导航菜单,好像CSS要配合JS才能写出好效果来,本款菜单同样用到了Js哦,菜单目前支持两级,下拉导航是我们经常用的一种菜单形式,把这个修改一下你就能用了,结构挺简单,相信你会做好的。

代码内容:

<!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>  <title>JS+CSS实现的二级下拉导航菜单_网页代码站(www.webdm.cn)</title>  <style type="text/css">  body,html{padding:0;margin:0;text-align:center;font:normal 14px 'arial';}  #mainNavBar{width:100%;background:#999;padding:10px 0;}  #nav{width:760px;height:30px;margin:0 auto;}  #nav ul{padding:0;margin:0;}  #nav ul li{position:relative;float:left;width:60px;height:30px;line-height:30px;overflow:hidden;list-style-type:none;}  #nav ul li a{display:block;color:#fff;text-decoration:none;}  #nav ul li a:hover{font-weight:bold;background:#666;}  #subNav{position:absolute;width:150px;top:30px;left:0px;padding:5px;background:#666;color:#fff;text-align:left;}  #subNav a{text-decoration:none;font-weight:normal;display:block;}  #subNav a:hover{color:#f00;background:#f00;}  </style>  </head>  <body>  <div id="mainNavBar">   <div id="nav">    <ul>     <li>      <a href="#">添加</a>      <div id="subNav">       <a href="#">日志</a>       <a href="#">分类</a>      </div>     </li>     <li>      <a href="#">管理</a>      <div id="subNav">       <a href="#">分类</a>       <a href="#">文章</a>      </div>     </li>     <li>      <a href="#">扩展</a>      <div id="subNav">       <a href="#">评论管理</a>       <a href="#">留言管理</a>       <a href="#">注销退出</a>      </div>     </li>    </ul>   </div>  </div>  <script language="javascript">  var nav=document.getElementById("nav").getElementsByTagName("li");  for(i=0;i<nav.length;i++){  nav[i].onmouseover=function(){   this.style.fontWeight="bold";   this.style.overflow="visible";   this.style.background="#666666";   }  nav[i].onmouseout=function(){   this.style.fontWeight="normal";   this.style.background="#999999"   this.style.overflow="hidden";   }  }  </script>  </body>  </html>  代码来自:http://www.webdm.cn/webcode/1b9d48fe-00fd-4dee-af1c-12a7e8a95d2e.html  
联系我们CONTACT 扫一扫
愿景:成为最专业的软件研发服务领航者
中睿信息技术有限公司 广州•深圳 Tel:020-38931912 务实 Pragmatic
广州:广州市天河区翰景路1号金星大厦18层中睿信息 Fax:020-38931912 专业 Professional
深圳:深圳市福田区车公庙有色金属大厦509~510 Tel:0755-25855012 诚信 Integrity
所有权声明:PMI, PMP, Project Management Professional, PMI-ACP, PMI-PBA和PMBOK是项目管理协会(Project Management Institute, Inc.)的注册标志。
版权所有:广州中睿信息技术有限公司 粤ICP备13082838号-2