jquery 图片放大镜,草稿版

<!DOCTYPE html>
<html lang="zh-cn">
<head>
	<meta charset="UTF-8">
	<title>js 放大镜</title>
	<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
	<style>
	*{
		margin: 0;
		padding: 0;
	}
	.tu{
		 500px;
	}
	.box{
		border:1px solid #000;
		 200px;
		height: 200px;
	}
	.box{
		background:url("https://gdp.alicdn.com/imgextra/i3/3446533752/TB2n3A7fOCYBuNkHFCcXXcHtVXa_!!3446533752.jpg") no-repeat;

	}
	</style>
</head>
<body>
	
	<img class="tu" src="https://gdp.alicdn.com/imgextra/i3/3446533752/TB2n3A7fOCYBuNkHFCcXXcHtVXa_!!3446533752.jpg" alt="">

	<div class="box"></div>


	<script>
	$(function(){
		console.log("1");

		$(".tu").mousemove(function(even){
			console.log(even)
			console.log(even.clientX);
			console.log(even.clientY);
			$(".box").css("background-position","-"+even.clientX+"px -"+even.clientY+"px")
		  });
	})

	</script>
</body>
</html>

  

原文地址:https://www.cnblogs.com/shaozhu520/p/9517730.html