0

我有一个网站,它有一个管理区域,用户需要在其中查看通知。

我用 CSS 下拉菜单设置了整个通知想法,但是一旦光标离开菜单,我似乎无法让菜单保持打开状态

我已将文件上传到 JSbin 希望有人可以帮助我

http://jsbin.com/ecegiy/1

它在那里看起来并不多,因为不包括所有图像和 mysql 连接文件,但链接中包含 css 菜单的想法。

4

1 回答 1

0

Ok, if you want to let the menu stay open I'll suggest:

  • Delete the css part of hover on sub-menu
    #menu li:hover ul.sub-menu { display: block; }
  • Give your menu an id
    <ul id="childDisplay" class="sub-menu">
  • Add the javascript to upper element that it's always visible
    <li onmouseover="menuVis.visible('childDisplay');" onmouseout="setTimeout('menuVis.unvisible(\'childDisplay\')',1000);">
  • Add the javascript class and method:

    function vis(){
        this.flag=0;
        this.flagUnv=0;
    
        this.visible=function(x){
          this.flag=this.flag+1;
          document.getElementById(x).style.display="block";
    
        }
    
    
        this.unvisible= function (x){
              this.flagUnv=this.flagUnv+1;
              if(this.flagUnv==this.flag)
                   document.getElementById(x).style.display="none";    
            }
    }
    menuVis=new vis();
    }
    

With this, the sub-menu will become invisible after 1000ms. If you want to keep it visibile "forever" just delete onmouseout section and the unvisible function.

于 2012-09-30T15:48:32.257 回答