图片放大镜 jQuery插件

插件网盘地址



/*传参使用jqzoom*/
$(function(){
	$('.jqzoom').jqzoom({
		zoomType: 'standard',/*遮罩层样式*/
		lens:true,/*鼠标滑入显示遮罩层*/
		preloadImages: false,/*预加载*/
		alwaysOn:false,/*初始是否显示遮罩层*/
		zoomWidth: 340,/*放大图片的宽高*/
		zoomHeight: 340,
		xOffset:10,/*放大图片距离原始图片距离*/
		yOffset:0,
		position:'right'/*放大图片位置*/
    });
});

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是两种jQuery图片放大镜的代码: 1. 使用HTML和CSS实现图片放大镜效果: ```html <div id="box"> <img src="./哈哈.jpg" alt=""> // 正常显示的图片 <div id="xiao"></div> </div> <div id="box2"> <img src="./哈哈.jpg" alt="" id="big"> // 要放大的图片 </div> <style> #box { position: relative; width: 400px; height: 400px; } #xiao { position: absolute; width: 100px; height: 100px; background-color: rgba(0, 0, 0, 0.5); display: none; } #box2 { position: relative; width: 400px; height: 400px; overflow: hidden; } #big { position: absolute; width: 800px; height: 800px; display: none; } </style> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script> $(document).ready(function() { $("#box").mousemove(function(e) { var x = e.pageX - $(this).offset().left; var y = e.pageY - $(this).offset().top; var xPercent = x / $(this).width(); var yPercent = y / $(this).height(); var bigImgWidth = $("#big").width(); var bigImgHeight = $("#big").height(); var moveX = -(bigImgWidth - $(this).width()) * xPercent; var moveY = -(bigImgHeight - $(this).height()) * yPercent; $("#big").css({ "left": moveX, "top": moveY }); $("#xiao").css({ "left": x - 50, "top": y - 50 }); }); $("#box").hover(function() { $("#xiao").show(); $("#big").show(); }, function() { $("#xiao").hide(); $("#big").hide(); }); }); </script> ``` 2. 使用jQuery插件实现图片放大镜效果: ```html <div id="smallBox"> <img src="/img/1.png" alt=""> <div id="zoom"></div> </div> <div id="bigBox"> <img src="/img/1.png" alt=""> </div> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="jquery.elevatezoom.js"></script> <script> $(document).ready(function() { $("#smallBox").elevateZoom({ zoomType: "inner", cursor: "crosshair", zoomWindowFadeIn: 500, zoomWindowFadeOut: 500 }); }); </script> ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值