商品名称jQuery实现鼠标滑过放大图片

鼠标图片  时间:2021-04-19  阅读:()

本特效效果模仿百度图片效果。效果图如下打开页面效果

鼠标放上去0.15秒放大的层从小到大展开

鼠标移开后弹出层消失

。页面代码如下

<!DOCTYPE htmlPUBLI C "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w 3.org/TR/xhtml1/DTD/xhtml1-transition al.dtd">

<HTML xmlns="http://w ww.w 3.org/1999/xhtml">

<HEAD>

<META c ontent="text/html; c harset=utf-8"http-equiv="Conte nt-Type">

<TITLE>demo</TITLE>

<SCRIPT language="JavaScript" type="text/javas cript" src="demo_files/jquery.js"></SCRIP T><STYLE>html,body,div,span,iframe,h 1,h2,h3,h4,h5,h6,p,a,font,img,strong,dl,dt,dd,ol,ul,li,field s et,form,label,legend{margin:0;padding:0;}a{ color:#fff; text-decoration:none;}a img{border:none;}li{ lis t-s tyle-typ e:none;}body{backg round:#000;color:#fff;font-size:12px; font:Arial ,Verda na,"宋体"}

.wrapper{overflow:hidden;width:1130px;margin:0 auto;}

.header{overflow:hidden;padding:20px 050px;}

.main{width:1000px;margin:0 auto 30px;overflow:hidde n;}

#detial{overflow:hidden;width:750px;paddi ng-top:20px;}

.shopPic{overflow:hidde n;w idth:720px; float:right;}

.shopPic a{float:left;display:inlin e-block;}

.detialItem{overflow:hidden;margin-bottom:5px;width:720px;}

.itemTop{ overflow:hidden; line-height:40px; border-bottom:1px solid #fff;margin-bottom:20px;}

.itemTop h2{float:left;margin-left:10px;}

.more{ float :right ;backg round:#fff; color :#333; displ ay:block;heigh t:20px; line-heigh t:20px;width:50px; text-align:cente r;margi n-top:12px;margi n-right :10px;font-famil y:'微软雅黑' ;}.more:hover{ text-dec oration:under line;}

.itemIfor{float:left;width:150px;float:left;margin-left:23px;}

.pic Title{ font-size:14px;font-weight:bold; c olor:#A0 BC 1 D; line-height:30px;padding:05px;}.itemIfor p{padding:05px; line-height:20px;}

.popup{width:300px;height:380px;background-c olor:#fff;border:solid 1 px#ccc;}

#tempdiv{overflow:hidden;display:none;posit ion:abs olute;}

</STYLE>

<META name="GENER ATOR"c ontent="MSHTM L 9.00.8112.16441">

</HEAD>

<BODY>

<div clas s="wrapper">

<div c las s="main">

<div id="detia l">

<div c las s="detialItem">

<div class ="itemT op"><h2>列表 1</h2><a href="#" class="more">More. .</a></div>

<div c las s="itemIfor">

<a href ="#"><img src ="demo_files/img3.jpg" width="150"

height="150" /></a>

<a href="#"class="picTi tle">商品名称</a>

<p>111.00</p>

</div>

<div c las s="itemI for">

<a href ="#"><img src ="demo_files/img6.jpg" width="150"height="150" /></a>

<a href="#"class="picTi tle">商品名称</a>

<p>222.00</p>

</div>

<div c las s="itemI for">

<a href ="#"><img src ="demo_files/img3.jpg" width="150"height="150" /></a>

<a href="#"class="picTi tle">商品名称</a>

<p>333.00</p>

</div>

<div c las s="itemI for">

<a href ="#"><img src ="demo_files/img6.jpg" width="150"height="150" /></a>

<a href="#"class="picTi tle">商品名称</a>

<p>123.00</p>

</div>

</div>

<div c las s="detialItem">

<div class ="itemT op"><h2>列表 2</h2><a href="#" class="more">More. .</a></div>

<div c las s="itemI for">

<a href ="#"><img src ="demo_files/img6.jpg" width="150"height="150" /></a>

<a href="#"class="picTi tle">商品名称</a>

<p>123.00</p>

</div>

<div c las s="itemIfor">

<a href ="#"><img src ="demo_files/img3.jpg" width="150"height="150" /></a>

<a href="#"class="picTi tle">商品名称</a>

<p>123.00</p>

</div>

<div c las s="itemI for">

<a href ="#"><img src ="demo_files/img6.jpg" width="150"height="150" /></a>

<a href="#"class="picTi tle">商品名称</a>

<p>123.00</p>

</div>

<div c las s="itemI for">

<a href ="#"><img src ="demo_files/img3.jpg" width="150"height="150" /></a>

<a href="#"class="picTi tle">商品名称</a>

<p>123.00</p>

</div>

</div>

</div>

</div>

</div>

<!--这个是弹出放大图片的模板-->

<div style="displ ay:none" id="templ ate">

<a href="Thref"><img src="Timg"width="150"heigh t="150"/></a>

<a href="Thref"class="picTitle">TprdName</a>

<p style="color:#000">Tprice</p>

</div>

<SCRIPT>var popupdiv={init:funct ion(){//初始化

$th is=th is;//保存本对象

$("#detia l .itemIfor").each(function(i){var children=$(this).children();var itemobj=new Object();itemo bj.href=$(child ren[0]).attr("href");//获取链接itemo bj.produ ctNam e=$(child ren[1]).text();//获取产品名称itemo bj.price =$(child ren[2]).text();//获取价格

$(child ren[0]).find("img").mouse enter (funct ion(){//给所有图片添加鼠标进入事件var templ ate=$("#templ ate").html();//获取模板

//替换模板内容template=$this.s etVa lue(template,/Thref/g,itemo bj.href);template=$this.s etValue(template,/TprdName/g,itemobj.productName);template=$this.s etValue(template,/Tprice/g,itemobj.pric e);template=$this.s etVa lue(template,/T img/g,$(this).attr("s rc"));var htmlobj=new Object();htmlobj.html=temp l ate;htmlo bj.offse t=$(this).posit ion();//获取图片精确位置htmlo bj.w idth =$(this).outer Width();//获取图片宽度htmlo bj.heigh t=$(this).outer Heigh t();//获取图片高度

$this.creat ePopu p(htmlo bj);//创建div

}).mouse leave (funct ion(){clear Timeo ut($this.popti mmer);});//鼠标移除图片时清除定时器 以避免鼠标移出了图片还弹出效果图

});

},

s etValue:function(template,reg,value){return template.replac e(reg,value);

},createPopup:function(opts){var div="<div id='tempdiv'><div clas s='popup'>"+opts.html+"</div><div>";if($("#temp d iv").html()!=nul l)

$("#tempdiv").remove();

$("body").appen d(div);

//设置定时器this.poptimmer=s etT imeout(func tion(){

$("#tempdiv").c s s({width:opts.width+"px",height:opts.height+"px",left:opts.offs et.left+"px",top:opts.offset.top+"px"}).show();var children=$("#tempdiv").children();

//计算放大图的实际大小var innerWidth=$(c hildren[0]).outerWidth();var innerHeight=$(children[0]).outerHeigh t();

//计算放大图的左顶点位置var diff=innerWidth-opts.w idth;var newTop=opts.offset.top-diff/2;var newLeft=opts.offset.left -diff/2;

$("#tempdiv").animate({w idth:inn erWidth+"p x",height:innerHeigh t+"px",left:newLe ft+"px",top:newTop+"px"

},{duration:150,s tep:func tion(){

//执行动画的时候每一步都改变图片大小

$(this).find("im g").attr({w idth:$(this).outerWidth(),h e ight:$(this).outerWidth()});

}

});//animate end

},500);//setTimeout end

$("#tempdiv").mous eleave(function(){

$(this).s top().html("").remove();

});

},popti mmer:null//定时器

}popupdiv.init();

</SCRIPT>

</BODY>

</HT ML>

图片和jq uery插件请放在demo_file文件夹中

pacificrack:VPS降价,SSD价格下降

之前几个月由于CHIA挖矿导致全球固态硬盘的价格疯涨,如今硬盘挖矿基本上已死,硬盘的价格基本上恢复到常规价位,所以,pacificrack决定对全系Cloud server进行价格调整,降幅较大,“如果您是老用户,请通过续费管理或升级套餐,获取同步到最新的定价”。官方网站:https://pacificrack.com支持PayPal、支付宝等方式付款VPS特征:基于KVM虚拟,纯SSD raid...

vpsdime7美元/月,美国达拉斯Windows VPS,2核4G/50GB SSD/2TB流量/Hyper-V虚拟化

vpsdime怎么样?vpsdime是2013年成立的国外VPS主机商,以大内存闻名业界,主营基于OpenVZ和KVM虚拟化的Linux套餐,大内存、10Gbps大带宽、大硬盘,有美国西雅图、达拉斯、新泽西、英国、荷兰机房可选。在上个月搞了一款达拉斯Linux系统VPS促销,详情查看:vpsdime夏日促销活动,美国达拉斯vps,2G内存/2核/20gSSD/1T流量,$20/年,此次推出一款Wi...

Hostodo(年付$34.99), 8TB月流量 3个机房可选

Hostodo 算是比较小众的海外主机商,这次九月份开学季有提供促销活动。不过如果我们有熟悉的朋友应该知道,这个服务商家也是比较时间久的,而且商家推进活动比较稳,每个月都有部分活动。目前有提供机房可选斯波坎、拉斯维加斯和迈阿密。从机房的地理位置和实际的速度,中文业务速度应该不是优化直连的,但是有需要海外业务的话一般有人选择。以前一直也持有他们家的年付12美元的机器,后来用不到就取消未续约。第一、开...

鼠标图片为你推荐
路由route存在问题的应用软件名单(2020年第四批)司机苹果5图书馆学、情报学期刊投稿指南ipadwifiIpad怎么用移动无线上网tcpip上的netbios网络连接详细信息上的netbios over tcpip是什么意思?tcpip上的netbiostcp 协议里的 netbios . 在哪,找不到win7如何关闭445端口如何判断445端口是否关闭icloudiphone没开启icloud的iphone怎么用find my iphone找回icloudiphone苹果6显示已停用请连接itunes什么意思
工信部域名备案查询 godaddy域名解析教程 花生壳域名贝锐 lnmp 59.99美元 天猫双十一抢红包 免费静态空间 国外php空间 ibox官网 cpanel空间 阿里云浏览器 域名评估 爱奇艺vip免费试用7天 服务器合租 宏讯 免费的asp空间 新加坡空间 免备案jsp空间 .htaccess 美国主机 更多