亲宝软件园·资讯

展开

javascript仿京东导航左侧分类导航下拉菜单效果

aubin 人气:0

本文实例为大家分享了类似于京东、淘宝商城左侧分类导航下拉菜单,供大家参考,具体内容如下

效果图:

 

实现代码:

<!DOCTYPE html>
<html>
<head>
  <meta charset="gb2312">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title></title>
  <style>
   *{margin:0;padding:0;}
   .ul{position:relative;width:200px;height:auto;} 
   .ul li{height:24px;line-height:24px;border-bottom:1px solid #ddd;text-align:center;font-size:12px;}
   .ul li a{display:block;background:#fff;color:#000;text-decoration:none;}
   .ul li a:hover{display:block;background:#000;color:#fff;text-decoration:none;}
   .ul li div{display:none;width:400px; height:auto;position:absolute;top:0;left:200px; background:#000; color:#fff;}
   .ul li div dl dd{float:left; width:100px;}
   .ul .liname div{display:block;}
  </style>
  <script>
    window.onload=function(){
      var aLi=document.getElementsByTagName("li");
      for(var i=0;aLi.length>i;i++){
        aLi[i].i=i;
        aLi[i].onmouseover=function(){
          this.className="liname";
 
          var h1=this.i*25;
          var h2=this.getElementsByTagName("div")[0].offsetHeight;
          if(h2<h1){
            this.getElementsByTagName("div")[0].style.top=h1+'px';
          }
           
        }
        aLi[i].onmouseout=function(){
          this.className="";
        }
      }
    }
  </script>
</head>
<body>
  <ul class="ul">
    <li>
      <a href="">类别1</a>
      <div class="div">
        <dl>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
        <https://img.qb5200.com/download-x/dl>
      </div>
    </li>
    <li>
    <a href="">类别2</a>
      <div class="div">
        <dl>
          <dd>类别2<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
        <https://img.qb5200.com/download-x/dl>
      </div>
    </li>
    <li><a href="">类别3</a><div class="div">
        <dl>
          <dd>类别3<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
        <https://img.qb5200.com/download-x/dl>
      </div>
      </li>
    <li><a href="">类别4</a><div class="div">
        <dl>
          <dd>类别4<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
        <https://img.qb5200.com/download-x/dl>
      </div>
      </li>
    <li><a href="">类别5</a><div class="div">
        <dl>
          <dd>类别5<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
        <https://img.qb5200.com/download-x/dl>
      </div>
      </li>
    <li><a href="">类别6</a><div class="div">
        <dl>
          <dd>类别6<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
        <https://img.qb5200.com/download-x/dl>
      </div>
      </li>
    <li><a href="">类别7</a><div class="div">
        <dl>
          <dd>类别7<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
        <https://img.qb5200.com/download-x/dl>
      </div>
      </li>
    <li><a href="">类别8</a><div class="div">
        <dl>
          <dd>类别8<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
          <dd>类别1<https://img.qb5200.com/download-x/dd>
        <https://img.qb5200.com/download-x/dl>
      </div>
      </li>
  </ul>
</body>
</html>

希望本文所述对大家学习javascript程序设计有所帮助。

加载全部内容

相关教程
猜你喜欢
用户评论