鱼眼菜单Demo

模仿做了个菜单截图:

 

 html:

 

ExpandedBlockStart.gif View Code
 1  <! DOCTYPE html >
 2 
 3  < html >
 4  < head >
 5      < title ></ title >
 6      < style  type ="text/css" >
 7          #container {  position : fixed ;  bottom : 0 ;  width : 100% ;  text-align : center ; }
 8          #container img {  width : 100px ;  height : 100px ;  cursor : pointer ; }
 9       </ style >
10  </ head >
11  < body >
12      < div  id ="container" >
13          < img  src ="31.png"  alt ="图标" />
14          < img  src ="33.png"  alt ="图标" />
15          < img  src ="35.png"  alt ="图标" />
16          < img  src ="37.png"  alt ="图标" />
17      </ div >
18      < script  src ="util.js"  type ="text/javascript" ></ script >
19      < script  type ="text/javascript" >
20           var  obj  =   new  util();
21       </ script >
22  </ body >
23  </ html >

 js:

ExpandedBlockStart.gif View Code
 1  function util() {
 2      this.distance = 350;  // 鼠标到圆心距离
 3       this.imgMaxWidth = 200;
 4      this.imgMaxHeight = 200;
 5      this.init();
 6 }
 7 util.prototype = {
 8     init:  function () {
 9          var boxObj = document.getElementById('container');
10          var imgList = boxObj.getElementsByTagName('img');
11          var _this =  this;
12         
13         document.onmousemove =  function (ev) {
14              var ev = ev || window.event;
15              for ( var i = 0; i < imgList.length; i++) {
16                  var a = ev.clientX - (imgList[i].offsetLeft + imgList[i].offsetWidth / 2);
17                  var b = ev.clientY - (imgList[i].offsetTop + imgList[i].offsetHeight / 2 + boxObj.offsetTop);
18                  var c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
19                  var spex = 1 - c / _this.distance;
20                  if (spex < 0.5) {
21                     spex = 0.5;
22                 }
23                 imgList[i].style.width = spex * (_this.imgMaxWidth) + 'px';
24                 imgList[i].style.height = spex * (_this.imgMaxHeight) + 'px';
25             }
26         }
27     }
28 }

 

/Files/MasterHeng/Menu.zip 

 

转载于:https://www.cnblogs.com/MasterHeng/archive/2011/12/01/2270637.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值