jquery实现多级下拉菜单

发布时间:2020年07月15日      浏览次数:158 次
<title>jquery实现多级下拉菜单</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
/* 一级菜单 */
#menu_main{ clear:both; height:30px; margin:0; padding:0; z-index:10001; }
      #menu_main li{ list-style:none; float:left; width:100px; height:30px; line-height:30px; margin:0; padding:0; margin-right:1px; text-align:center; background-color:#034288; display:block; position:relative; }
            #menu_main li a{ width:90px; margin:0; padding:0 10px; box-sizing: border-box; font-size:14px; color:#FFF; text-decoration:none; white-space:nowrap; text-overflow:clip; display:block; overflow:hidden; }
                  /* 二级菜单 */
                  #menu_main ul{ width:auto; width:100px; margin:0; padding:0px; position:absolute; top:29px; left:0; display:none; visibility:hidden; z-index:10002;}
                        #menu_main ul li { width:100%; height:30px; line-height:30px; margin:0; padding:0px; text-align:left; background:none; background-color:#E2EEF5; display:block; visibility:visible;}
                              #menu_main ul li a { width:100%; margin:0; padding:0 8px; box-sizing: border-box; font-size:14px; color:#223e62; text-decoration:none; white-space:nowrap; text-overflow:clip; border-left:1px #ddd solid; display:block; overflow:hidden; }
                              #menu_main ul li:hover{ background-color:#B0D3F0;}
                        /* 三级菜单 */
                        #menu_main ul ul{ top:0px; left:98%; width:120px; display:none; visibility:hidden; z-index:10003; }
                              #menu_main ul ul li { text-align:left; }
                              /* 四级菜单 */
                              #menu_main ul ul ul{ top:0px; left:98%; width:120px; display:none; visibility:hidden; z-index:10004; }
                                    #menu_main ul ul ul li { text-align:left; }

</style>
<script src="js/jquery1_13.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
      $("#menu_main li").hover(
            function () {
                  $(this).children('ul').hide();
                  $(this).children('ul').slideDown('fast');
            },
            function () {
                  $('ul', this).slideUp('fast');
            }
      );
});
</script>
<ul id="menu_main">
      <li><a href="#">一级菜单1</a></li>
      <li><a href="#">一级菜单2 ∨</a>
            <ul>
                  <li><a href="#">二级菜单1</a></li>
                  <li><a href="#">二级菜单2 ></a>
                        <ul>
                              <li><a href="#">三级菜单1</a></li>
                              <li><a href="#">三级菜单2 ></a>
                                    <ul>
                                          <li><a href="#">四级菜单1</a></li>
                                          <li><a href="#">四级菜单2</a></li>
                                    </ul>
                              </li>
                        </ul>
                  </li>
            </ul>
      </li>
</ul>
免责声明:本站相关技术文章信息部分来自网络,目的主要是传播更多信息,如果您认为本站的某些信息侵犯了您的版权,请与我们联系,我们会即时妥善的处理,谢谢合作!