日期:2014-05-16  浏览次数:20490 次

js控制div层
有一个导航,希望在鼠标移动到每一个选项的时候能显示出子项目。
但由于不同显示器分辨率的原因,子项目显示的位置不能相对固定。
目前,只针对800*768的实现:
JScript code
#Layer1{left:40px;}
#Layer2{left:100px;}
#Layer3{left:200px;}
#Layer4{left:300px;}
#Layer5{left:400px;}
#Layer6{left:auto;right:80px;}
#Layer7{left:auto;right:80px;}



jsp页面中:
CSS code
<div id="Layer2" class="submenu" onMouseOver="MM_showHideLayers('Layer2','','show')" onMouseOut="MM_showHideLayers('Layer2','','hide')"> 
<div class="">
      <ul>
          <li><a href=""></a></li>
          <li><a href=""></a></li>
          <li><a href=""></a></li>
          <li><a href=""></a></li>
          <li><a href=""></a></li>
          <li class="subright"></li>
      </ul>
    </div>
</div>

    
    
<div id="Layer3" class="submenu" onMouseOver="MM_showHideLayers('Layer3','','show')" onMouseOut="MM_showHideLayers('Layer3','','hide')"> 
 <div class="">
  <ul>
      <li><a href=""></a></li>
      <li><a href=""></a></li>
      <li><a href=""></a></li>
      <li><a href=""></a></li>
      <li><a href=""></a></li>
      <li><a href=""></a></li>
      <li class="subright"></li>
  </ul>
</div>
</div>
<div id="Layer4" class="submenu" onMouseOver="MM_showHideLayers('Layer4','','show')" onMouseOut="MM_showHideLayers('Layer4','','hide')"> 
 <div class="">
  <ul>
      <li><a href=""></a></li>
      <li><a href=""></a></li>
      <li class="subright"></li>
  </ul>
</div>
</div>
<div id="Layer5" class="submenu" onMouseOver="MM_showHideLayers('Layer5','','show')" onMouseOut="MM_showHideLayers('Layer5','','hide')"> 
 <div class="">
  <ul>
      <li><a href=""></a></li>
      <li><a href=""></a></li>
      <li><a href=""></a></li>
      <li><a href=""></a></li>
      <li class="subright"></li>
  </ul>
</div>
</div>
<div id="Layer6" class="submenu" onMouseOver="MM_showHideLayers('Layer6','','show')" onMouseOut="MM_showHideLayers('Layer6','','hide')"> 
 <div class="">
  <ul>
      <li><a href=""></a></li>
      <li><a href=""></a></li>
      <li><a href=""></a></li>
      <li class="subright"></li>
  </ul>
</div>
</div>
<div id="Layer7" class="submenu" onMouseOver="MM_showHideLayers('Layer7','','show')" onMouseOut="MM_showHideLayers('Layer7','','hide')"> 
 <div class="">
  <ul>
      <li><a href=""></a></li>
      <li><a href=""></a></li>
      <li><a href=""></a></li>
      <li class=