欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > 能源 > 前端JS特效第45集:js实现图片放大和拖拽特效

前端JS特效第45集:js实现图片放大和拖拽特效

2025/6/27 8:48:38 来源:https://blog.csdn.net/2401_85903333/article/details/139999847  浏览:    关键词:前端JS特效第45集:js实现图片放大和拖拽特效

js实现图片放大和拖拽特效,先来看看效果:

部分核心的代码如下(全部代码在文章末尾):

<!DOCTYPE html>
<html>
<head><meta charset="utf-8"><title>js实现图片放大和拖拽特效</title><meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"><link rel="stylesheet" href="css/style.css"><script type="text/javascript" src="js/drag_map.js"></script><style type="text/css">body{font-size: 12px;font-family: "Verdana" , "Arial" , "Helvetica" , "sans-serif";} td{font-size: 12px; line-height: 150%;} TD{font-size: 12px; color: #000000;} A{font-size: 12px; color: #000000;} #Layer1{z-index: 100; position: absolute; top: 150px;} #Layer2{z-index: 1; position: absolute;}</style><script type="text/JavaScript">function MM_reloadPage(init) {if (init == true) with (navigator) {if ((appName == "Netscape") && (parseInt(appVersion) == 4)) {document.MM_pgW = innerWidth; document.MM_pgH = innerHeight; onresize = MM_reloadPage;}}else if (innerWidth != document.MM_pgW || innerHeight != document.MM_pgH) location.reload();}MM_reloadPage(true);</script>
</head>
<body onLoad="" onmouseup="document.selection.empty()" oncontextmenu="return false"onselectstart="return false" ondragstart="return false" onbeforecopy="return false"style="overflow-y: hidden; overflow-x: hidden" oncopy="document.selection.empty()"leftmargin="0" topmargin="0" onselect="document.selection.empty()" marginheight="0"marginwidth="0"><div id="Layer1"><table cellspacing="2" cellpadding="0" border="0"><tbody><tr><td>&nbsp;</td><td><img title="向上" style="cursor: hand" onClick="clickMove('down')" height="20" src="images/up.gif"width="20"></td><td>&nbsp;</td></tr><tr><td><img title="向左" style="cursor: hand" onClick="clickMove('right')" height="20" src="images/left.gif"width="20"></td><td><img title="还原" style="cursor: hand" onClick="realsize();" height="20" src="images/zoom.gif"width="20"></td><td><img title="向右" style="cursor: hand" onClick="clickMove('left')" height="20" src="images/right.gif"width="20"></td></tr><tr><td>&nbsp;</td><td><img title="向下" style="cursor: hand" onClick="clickMove('up')" height="20" src="images/down.gif"width="20"></td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td><img title="放大" style="cursor: hand" onClick="bigit();" height="20" src="images/zoom_in.gif"width="20"></td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td><img title="缩小" style="cursor: hand" onClick="smallit();" height="20" src="images/zoom_out.gif"width="20"></td><td>&nbsp;</td></tr></tbody></table></div><p><br></p><div id="hiddenPic" style="z-index: 1; left: 0px; visibility: hidden; width: 0px;position: absolute; top: 150px; height: 0px"><img src="http://ww2.sinaimg.cn/large/adde8400gw1eeazlmtqa8j20qd0mdadm.jpg" border="0" name="images2"></div><div class="dragAble" id="block1" onMouseOver="dragObj=block1; drag=1;" style="z-index: 10;left: 0px; width: 0px; position: absolute; top: 150px; height: 0px" onMouseOut=""drag="0"><img onmousewheel="return onWheelZoom(this)" style="zoom: 0.7" src="images/adde8400gw1eeazlmtqa8j20qd0mdadm.jpg"border="0" name="images1"></div>
<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">
<p>适用浏览器:IE8、360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗.</p>
</div>
</body>
</html>

全部代码:js实现图片放大和拖拽特效

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词