自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(1)
  • 资源 (1)
  • 收藏
  • 关注

原创 推荐几个网站www.mfdzs.com 免费电子书下载

www.mfdzs.com 免费电子书下载www.txtwb.com手机小说下载www.66ring.com 手机铃声下载

2010-07-04 17:09:51 3269

仿淘宝js放大镜效果

仿淘宝js放大镜效果 核心代码 malmg.onmouseover = function(){ showimg.style.display = "block"; bigimg.style.display = "inline"; show_half = showimg.offsetHeight/2; maxWidth = smalmg.clientWidth - showimg.offsetWidth; maxHeight = smalmg.clientHeight - showimg.offsetHeight; //上面两个变量指明showimg允许活动的区域 }; smalmg.onmousemove = function(e){ e = e || window.event;//兼容多个浏览器的event参数模式 var num=bigimg.clientWidth/showimg.clientWidth; var Top = mousePosition(e).y - smalmg.offsetTop - show_half; var Left = mousePosition(e).x - smalmg.offsetLeft - show_half; //获取当前移动的showimg位置 计算方法是 鼠标坐标 - 最外面容器的坐标 - 滤镜图的宽(高)的/2 Top = Top<0?0:Top>maxHeight?maxHeight:Top; Left = Left<0?0:Left>maxWidth?maxWidth:Left; showimg.style.top = Top + "px"; showimg.style.left = Left + "px"; bigimg.style.background = "url("+small_url+") -"+Left*num+"px -"+Top*num+"px no-repeat"; };

2010-10-20

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除