<!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>
*js图片放大
于 2018-06-01 17:02:22 首次发布