<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>图片放大镜</title>
</head>
<style>
*{ padding:0; margin:0}
.fdj{}
.fdj .small-wrap{ overflow:hidden; float:left}
.fdj .small-main{ width:266px; height:231px; position:relative}
.fdj .small-main img{ width:100%; height:100%}
.fdj .small-main .mask{ display:none; cursor:crosshair; position:absolute; left:0; top:0;width:100px; height:80px; background:rgba(0,0,0,.3)}
.fdj .bot-main{ width:266px; height:70px; overflow:hidden; position:relative;background-color: #F1F0F0; margin-top:2px;}
.fdj .bot-main .btn{ z-index:99; cursor:pointer; position:absolute; top:0; width:14px; height:70px; background-color:#ccc; color:#fff; line-height:70px; text-align:center}
.fdj .bot-main .prev{ left:0;}
.fdj .bot-main .next{ right:0;}
.fdj .bot-main .pic-list{ width:238px; height:70px; position:absolute; left:14px;}
.fdj .bot-main .list{ width:3000px; position:absolute; left:0; top:0;}
.fdj .bot-main .list li{ float:left; list-style:none}
.fdj .bot-main .list img{ width:70px; height:46px; margin:12px 0 0 4px;border:2px solid #F1F0F0}
.fdj .bot-main .list .active img{border:2px solid #959595}
.fdj .big-wrap{width:266px; height:231px; border:1px solid #ccc; float:left; overflow:hidden; display:none; position:relative}
.fdj .big-wrap img{ position:absolute; left:0; top:0; min-width:600px; min-height:700px;}
</style>
<body> <div class="fdj imageZoom">
<div class="small-wrap">
<div class="small-main">
<img src="http://0.thumb.pc6.com/thumb/up/2016-1/2016126154311097190_225_260.jpg">
<div class="mask"></div>
</div>
<div class="bot-main">
<span class="btn prev">《</span>
<div class="pic-list">
<ul class="list">
<li class="active"><img src="http://0.thumb.pc6.com/thumb/up/2016-1/2016126154311097190_225_260.jpg"></li>
<li><img src="http://www.guanfang123.com/Uploads/Picture/20150925/5604e6e0ced0c.jpg"></li>
<li><img src="http://www.guanfang123.com/Uploads/Picture/20150925/5604e6888e257.jpg"></li>
<li><img src="http://www.guanfang123.com/Uploads/Picture/20150925/5604e5bedce24.jpg"></li>
<li><img src="http://www.guanfang123.com/Uploads/Picture/20150925/5604e481ac8e8.png"></li>
<li><img src="http://www.guanfang123.com/Uploads/Picture/20150925/5604e2c9725f8.jpg"></li>
<li><img src="http://www.guanfang123.com/Uploads/Picture/20150923/56023b44d65e2.jpg"></li>
</ul>
</div>
<span class="btn next">》</span>
</div>
</div>
<div class="big-wrap"><img src="http://0.thumb.pc6.com/thumb/up/2016-1/2016126154311097190_225_260.jpg"></div>
</div>
<script src="soft/js/global.js"></script>
<script>
;(function(){
$.fn.imageZoom = function(options){
var defaults = {};
var sets = $.extend(defaults , options); this.each(function(){
var _this=$(this);
var small_wrap=_this.find(".small-main");//小图
var big_wrap=_this.find(".big-wrap");//大图
var mask=_this.find(".mask");//遮罩
var oul=_this.find('ul');
var oli=oul.find('li');
var i=0,small_w,small_h,big_w,big_h,blc_w,blc_h;
oul.width(oli.outerWidth(true)*oli.length); //切换缩略图
_this.find('.next').click(function(){
i>=oli.length-3?i=0:i++;
oul.animate({'left':-i*oli.outerWidth(true)});
});
_this.find('.prev').click(function(){
i<=0?i=oli.length-3:i--;
oul.animate({'left':-i*oli.outerWidth(true)});
}); oli.hover(function(){
var _src=$(this).find("img").attr('src');
$(this).addClass("active").siblings().removeClass("active");
small_wrap.find("img").attr("src",_src);
big_wrap.find("img").attr("src",_src);
}); //小图移动
small_wrap.mousemove(function(e){
small_w=small_wrap.width()-mask.width();
small_h=small_wrap.height()-mask.height();
big_w=big_wrap.find("img").width()-big_wrap.width();
big_h=big_wrap.find("img").height()-big_wrap.height();
blc_w=small_w/big_w;
blc_h=small_h/big_h; mask.show();
big_wrap.show();
var maskLeft = mask.position().left;
var maskTop = mask.position().top;
var X=e.pageX-mask.width()/2;
var Y=e.pageY-mask.height()/2;
if(X<=0){X=0};
if(Y<=0){Y=0};
if(X>=$(this).width()-mask.width()){
X=$(this).width()-mask.width()
};
if(Y>=$(this).height()-mask.height()){
Y=$(this).height()-mask.height()
};
mask.css({'left':X,'top':Y});
big_wrap.find("img").css({'left':-X/blc_w,'top':-Y/blc_h});
}).mouseout(function(){
mask.hide();
big_wrap.hide();
});
});
};
})(jQuery) $(function(){
$('.imageZoom').imageZoom(); })
</script>
</body>
</html>

实例截图:

jquery 产品查看放大镜组件的更多相关文章

  1. 基于jQuery仿淘宝产品图片放大镜代码

    今天给大家分享一款 基于jQuery淘宝产品图片放大镜代码.这是一款基于jquery.imagezoom插件实现的jQuery放大镜.适用浏览器:IE8.360.FireFox.Chrome.Safa ...

  2. 基于jQuery仿淘宝产品图片放大镜特效

    在开发商城的时候,往往会用到图片的放大功能,这里把自己在近期项目中使用的放大镜特效做一下总结(非插件). 放大镜效果 常用的js组件jquery.imagezoom,jquery.jqzoom,jqu ...

  3. Jquery图片上传组件,支持多文件上传

    Jquery图片上传组件,支持多文件上传http://www.jq22.com/jquery-info230jQuery File Upload 是一个Jquery图片上传组件,支持多文件上传.取消. ...

  4. 分享一个discuz touch端的jQuery下拉刷新组件

    在线Demo 最近装了个discuz论坛, 趣股VIP吧,发现里面内置的jQuery上拉刷新组件写得还行,STATICURL可以用'http://o9gzet7tk.bkt.clouddn.com/i ...

  5. jquery图片查看插件,支持旋转、放大、缩小、拖拽、缩略图(仿qq图片查看)

    最近做了一个jquery图片查看的插件,目的是能精确查看图片的详情,插件支持图片旋转.放大.缩小.拖拽.缩略图显示,界面效果是按照window的qq查看图片功能写的,当然不尽相同. 具体功能: 1. ...

  6. js,onblur后下一个控件获取焦点判断、html当前活跃控件、jquery版本查看、jquery查看浏览器版本、setTimeout&setInterval

    需求: input控件在失去焦点后直接做验证,验证通不过的话,显示相应错误.但是如果失去焦点后点击的下个控件是比较特殊的控件(比如,退出系统),那么不执行验证操作,直接退出系统(防止在系统退出前,还显 ...

  7. jquery星级评论打分组件

    <!DOCTYPE HTML><html> <head> <meta charset="utf-8"><title>jq ...

  8. 查看 activex 组件的方法

    查看 activex 组件的方法 可以使用的工具COMRaider 直接安装 并选择对应的类型即可查看相关的信息,比OLE/COM Object Viewer 简洁方便. 具体的操作如下: 随意选择一 ...

  9. 基于jQuery封装的分页组件

    前言: 由于项目需要实现分页效果,上jQuery插件库找了下,但是木有找到自己想要的效果,于是自己封装了个分页组件. 思路: 主要是初始化时基于原型建立的分页模板然后绑定动态事件并实现刷新DOM的分页 ...

随机推荐

  1. FastJson基本使用

    在发展中Android的过程中.假设我们常与server联系,更新数据等,然后,json它必须是一个良好的数据格公式,但随着json.使用原生的解析也能够,可是非常不高效,所以这里介绍两种json数据 ...

  2. Tomcat通过JNDI方式链接MySql数据库

    原文:Tomcat通过JNDI方式链接MySql数据库 拷贝MySQL的JDBC驱动到Tomcat的lib路径下 配置全局数据源或者单个Web应用的局部数据源 局部数据源 在Tomcat的conf/C ...

  3. Chain of Responsibility - 责任链模式

    定义 使多个对象都有机会处理请求,从而避免请求的发送者和接受者之间的耦合度. 案例 比方如今有一个图形界面,它包含一个应用Application类,一个主窗体Window,一个buttonButton ...

  4. openstack 网络简史

    openstack 网络简史 研究openstack有2个月的时间,这段时间从网上获取N多宝贵资料,对我的学习有非常大帮助,在加上我自己的研究,最终对openstack整个网络体系有了个浅显的认识,写 ...

  5. Javascript学习5 - 函数

    原文:Javascript学习5 - 函数 在Javascript中,函数和对象是交织在一起的.有些函数的特性与对象相关联.这一点的内容在第六部分会讨论到. 这一部分主要讨论函数与其它比较熟悉的语言( ...

  6. rabbitMQ说明文档

    rabbitMQ是什么 RabbitMQ     是由     LShift     提供的一个     Advanced Message Queuing Protocol (AMQP)     的开 ...

  7. 管道通信(使用popen和pclose功能简单的控制管道)

    函数原型: FILE *popen(const char * command ,const char *mode) int pclose(FILE * stream) 当心: 采用popen和pclo ...

  8. ASP.NET MVC+EF框架+EasyUI实现权限管理系列(15)-用户登录详细错误和权限数据库模型设计

    原文:ASP.NET MVC+EF框架+EasyUI实现权限管理系列(15)-用户登录详细错误和权限数据库模型设计     ASP.NET MVC+EF框架+EasyUI实现权限管系列 (开篇)    ...

  9. js中prototype用法(转)

    JavaScript能够实现的面向对象的特征有:·公有属性(public field)·公有方法(public Method)·私有属性(private field)·私有方法(private fie ...

  10. 【足迹C++primer】49、超载,变化,运营商

    超载,变化,运营商 Conversion Operators 转换操作符 operator type() const Conversions to an array or a function typ ...