*js图片放大

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>商品详情</title>
<script src="js/jquery-3.3.1.js"></script>
<script>
$(function(){
	   var $can = $("canvas");//jquery對象是一个数组对象
	   var ctx = $can[0].getContext("2d");
	   //选取id为photo的元素的i子元素img
	   var $img = $("#photo>img");
	   $img.mousemove(function(event){
		       $can.show();//显示隐藏的画布
			   ctx.clearRect(0,0,1000,1000);
			   //ctx.drawImage(img,picCutX,picCutY,picSizeX,picSizeY,showPicX,showPicY,showSizeX,showSizeY);
	                   //picCutX,picCutY表示所截取部分左上角在原图片上的坐标
	                   //picSizeX,picSizeY表示所截取部分在原图上的大小
	                   //showPicX,showPicY表示截取部分左上角在canvas上显示的坐标
	                   //showSizeX,showSizeY表示截取部分在canvas上显示的大小
			   ctx.drawImage($img[0],event.offsetX,event.offsetY,200,200,0,0,400,400);
	   });
	   $img.mouseout(function(){
	           $can.hide();//隐藏画布
	   });
});
</script>
<style>
body{width:1200px; margin:auto;}
*{ margin:0; padding:0;}

#title{
	background-color:#999;
	height:40px;
}
#product{
	border:1px solid #999;
	overflow:hidden;
}
#photo{
	border:1px solid #999;
	width:400px;
	height:400px;
	float:left;
}
#photo img{
	width:100%;
	height:100%;
}
#info{
	border:1px solid #999;
	width:794px;
	height:400px;
	float:left;
}
#info table{
	width:100%;
	height:100%;
}
#adv{
    border:2px solid #999;
	
}
canvas{
	position:fixed !important;
	left:480px;
	top:44px;
	z-index:1;
	width:400px;
	height:400px;
	background:#CCC;
	display:none;
}
</style>
<script>
    /*确认加入购物车*/
	/*确认提交订单*/
</script>
</head>

<body>
<div id="header"></div>


<div id="content">

   <div id="title"><h2>商店名称</h2></div>
   
   <div id="product">
        <div id="photo"><img src="img/list3_big.png"/></div>
        <canvas></canvas>
        <div id="info">
             <table border="1px" cellspacing="0" cellpadding="0">
                 <tr>
                     <td>商品名称</td>
                     <td>华硕笔记本</td>
                 </tr>
                 <tr>
                     <td>商品简介</td>
                     <td>酷睿i7八代/独显4G/8G内存</td>
                 </tr>
                 <tr>
                     <td>商品价格</td>
                     <td>¥6000</td>
                 </tr>
                 <tr>
                     <td>商品库存</td>
                     <td>10</td>
                 </tr>
                 <tr>
                     <td>商品销量</td>
                     <td>10</td>
                 </tr>
                 <tr>
                     <td>购买数量</td>
                     <td>-1+</td>
                 </tr>
                 <tr>
                     <td>总价格</td>
                     <td>¥6000</td>
                 </tr>
                 <tr>
                     <td><a href="">加入购物车</a></td>
                     <td><a href="">直接下订单</a></td>
                 </tr>
             </table>
        </div>
   </div>
   
   <div id="adv">本店推荐同类商品</div>
</div>


<div id="footer"></div>
</body>
</html>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值