页面左侧隐藏弹出式菜单,跟随页面滚动!

    前段时间在网上找了很多关于菜单的例子,才发现菜单的样式太多了,觉得这种隐藏在页面左侧的弹出式菜单比较好看,仔细研究了一番,并且简化了一下,自己做了一个例子!

    将以下代码复制到文本文档,修改后缀为.html,然后双击即可看到效果(注:只能在IE浏览器中有效果,其他的浏览器没试过,firefox上不行)

 <!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> new document </title>
  <meta name="generator" content="editplus" />
  <meta name="author" content="" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
 </head>

<style>
#menu{
visibility:hidden;
cursor:hand;
position:absolute;
top:150px;
}
#menu table{
width:150px;
background-color:black;
border-style:none;
cursor:hand;
}
.bar{
background-color:#0099FF;
font-size:16px;
font-weight:bold;
text-align:center;
}
.menu{
text-align:center;
width:16px;
background-color:#FF6666;
font-size:13px;
}
.menuItem{
background-color:white;
height:20px;
font-size:12px;
text-align:center;
}
</style>
<script language="JavaScript">
 function move(x) {
  menu.style.pixelLeft += x;
  menu.style.visibility = "visible";
 }
 function positionmenu(){
  move(-132);
 }
 function makeStatic() {
  if (typeof window.pageYOffset != 'undefined') {
      diffY = window.pageYOffset;
  }
  else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
      diffY = document.documentElement.scrollTop;
  }
  else if (typeof document.body != 'undefined') {
      diffY = document.body.scrollTop;
  }
  menu.style.pixelTop=diffY+150;
 }
 setInterval("makeStatic()",1);
 window.οnlοad=positionmenu;
</script>
<body>
 <div id="menu" οnmοuseοver="move(132)" οnmοuseοut="move(-132)">
 <table cellpadding="0" cellspacing="1">
  <tr>
   <td class="bar">
    Menu
   </td>
   <td class="menu" rowspan="100">
    菜<br><br><br>单
   </td>
  </tr>
  <tr>
   <td class="menuItem">
    网络管理
   </td>
  </tr>
  <tr>
   <td class="menuItem">
    修改密码
   </td>
  </tr>
  <tr>
   <td class="menuItem">
    数据查询
   </td>
  </tr>
  <tr>
   <td class="menuItem">
    数据查询
   </td>
  </tr>
  <tr>
   <td class="menuItem">
    数据查询
   </td>
  </tr>
  <tr>
   <td class="menuItem">
    数据查询
   </td>
  </tr>
 </table>
 </div>
 <div style="height:2000px;">
 </div>
</body>
</html>

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值