jquery 产品查看放大镜组件
<!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 产品查看放大镜组件的更多相关文章
- 基于jQuery仿淘宝产品图片放大镜代码
今天给大家分享一款 基于jQuery淘宝产品图片放大镜代码.这是一款基于jquery.imagezoom插件实现的jQuery放大镜.适用浏览器:IE8.360.FireFox.Chrome.Safa ...
- 基于jQuery仿淘宝产品图片放大镜特效
在开发商城的时候,往往会用到图片的放大功能,这里把自己在近期项目中使用的放大镜特效做一下总结(非插件). 放大镜效果 常用的js组件jquery.imagezoom,jquery.jqzoom,jqu ...
- Jquery图片上传组件,支持多文件上传
Jquery图片上传组件,支持多文件上传http://www.jq22.com/jquery-info230jQuery File Upload 是一个Jquery图片上传组件,支持多文件上传.取消. ...
- 分享一个discuz touch端的jQuery下拉刷新组件
在线Demo 最近装了个discuz论坛, 趣股VIP吧,发现里面内置的jQuery上拉刷新组件写得还行,STATICURL可以用'http://o9gzet7tk.bkt.clouddn.com/i ...
- jquery图片查看插件,支持旋转、放大、缩小、拖拽、缩略图(仿qq图片查看)
最近做了一个jquery图片查看的插件,目的是能精确查看图片的详情,插件支持图片旋转.放大.缩小.拖拽.缩略图显示,界面效果是按照window的qq查看图片功能写的,当然不尽相同. 具体功能: 1. ...
- js,onblur后下一个控件获取焦点判断、html当前活跃控件、jquery版本查看、jquery查看浏览器版本、setTimeout&setInterval
需求: input控件在失去焦点后直接做验证,验证通不过的话,显示相应错误.但是如果失去焦点后点击的下个控件是比较特殊的控件(比如,退出系统),那么不执行验证操作,直接退出系统(防止在系统退出前,还显 ...
- jquery星级评论打分组件
<!DOCTYPE HTML><html> <head> <meta charset="utf-8"><title>jq ...
- 查看 activex 组件的方法
查看 activex 组件的方法 可以使用的工具COMRaider 直接安装 并选择对应的类型即可查看相关的信息,比OLE/COM Object Viewer 简洁方便. 具体的操作如下: 随意选择一 ...
- 基于jQuery封装的分页组件
前言: 由于项目需要实现分页效果,上jQuery插件库找了下,但是木有找到自己想要的效果,于是自己封装了个分页组件. 思路: 主要是初始化时基于原型建立的分页模板然后绑定动态事件并实现刷新DOM的分页 ...
随机推荐
- 高通公司 MSM8K GPT异常原因分析无法开机的问题
问题分析过程如下面: 一. MSM8916台gpt概率问题:采用QPST emmc software download下载软件工具后,无法开机.例如下面的附图: log分析是userdata分区未成功 ...
- 安卓模拟器错误: Could not open
在进行android模拟器測试的时候,出现下面错误,进度条满了之后就没反应了.图例如以下: 引起这个问题的可能原因有非常多: 原因一:由于我们採用的是绝对路径定位.也就是说在环境变量里面把路径写死了, ...
- WinDbg调试.NET
WinDbg调试.NET程序入门 俗话说:万事开头难! 自从来到新公司遇到性能问题后,需要想办法解决这个问题,但是一直没有合适的性能分析工具,然后找到StevenChennet 大神帮忙,他用WinD ...
- Windows Cygwin Redis 安装(转)
在win平台下编译Redis一般有两种方式: 1. 基于MS VC进行编译,生成原生可执行文件 该方式需要创建MSVC项目文件以及对Redis源码进行适当调整. 这里提供一个可行版本,由微软开放团队进 ...
- oracle数据库全然恢复和不全然恢复以及运行用户管理辈分恢复
比較全然恢复和不全然恢复: 一.全然恢复:将数据库恢复到当前最新状态,包含直至请求恢复时进行的全部已提交的数据更改 二.不全然恢复:将数据库恢复到请求恢复操作之前指定的过去时间点 一.全然恢复过程 以 ...
- 半平面交总结and模板
博客原文地址:http://blog.csdn.net/xuechelingxiao/article/details/40859973 这两天刷了POJ上几道半平面交,对半平面交有了初步的体会,感觉半 ...
- java数据结构系列之——数组(1)
import javax.management.RuntimeErrorException; public class MyArray { private long array[]; private ...
- ORA-07445: :一个意料之外的问题发生了 核心转储 [ldxsnf()+625] [SIGSEGV
ALERT登录错误消息: Mon Jan 20 15:03:22 2014 Incremental checkpoint up to RBA [0x442f.abd.0], current log t ...
- JUnit4.8.2来源分析-2 org.junit.runner.Request
JUnit4.8.2源代码,最为yqj2065兴趣是org.junit.runner.Request,现在是几点意味着它? ①封装JUnit的输入 JUnit4作为信息处理单元,它的输入是单元測试类- ...
- 2.cocos2dx 3.2在语法的差异,lambada使用表达式和function和bind使用功能
1 打开 - 内置T32 Cocos2dx-3.2一个专案 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdG90b3R1enVvcXVhb ...