网页右侧弹出有缓冲效果的工具栏

 1 <!DOCTYPE html>
 2 <head>
 3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 4 <title>网页右侧弹出固定伸缩框</title>
 5 <style type="text/css">
 6 #common_box{width:300px;position:fixed;_position:absolute;right:0;top:40%;border:1px solid #789;background:#fff;z-index:88}
 7 #cli_on{width:30px;height:180px;float:left;cursor:pointer;background:#ac8932;text-align:center;line-height:180px}
 8 </style>
 9 </head>
10 
11 <body>
12 
13 <div id="common_box">
14  <div id="cli_on">+</div>
15  <div>
16   这里放置菜单内容
17  </div>
18 </div>
19 
20 </body>
21 </html>
22 <script type="text/javascript">
23 window.onload = function() {
24  var combox = document.getElementById("common_box");
25  var cli_on = document.getElementById("cli_on");
26  var flag = true, timer = null, initime = null, r_len = 0;
27  
28  cli_on.onclick = function () {
29   /*如果不需要动态效果,这两句足矣
30   combox.style.right = flag?'-270px':0;
31   flag = !flag;
32   */
33   clearTimeout(initime);
34   //根据状态flag执开展开收缩
35   if (flag) {
36    
37    timer = setInterval(slideright, 10);
38   } else {
39    
40    timer = setInterval(slideleft, 10);
41   }
42  }
43  
44  //展开
45  function slideright() {
46   if (r_len <= -270) {
47    clearInterval(timer);
48    flag = !flag;
49    return false;
50   } else {
51    r_len -= 5;
52    combox.style.right = r_len + 'px';
53   }
54   
55  }
56  
57  //收缩
58  function slideleft() {
59   if (r_len >= 0) {
60    clearInterval(timer);
61    flag = !flag;
62    return false;
63   } else {
64    r_len += 5;
65    combox.style.right = r_len + 'px';
66   }
67  }
68  
69  //加载后3秒页面自动收缩
70  initime = setTimeout("cli_on.click()", 3000);
71 }
72 </script>

 

转载于:https://www.cnblogs.com/aypnia/p/3285300.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值