原生JS实现放大镜 鼠标移入切换图片 点击出现弹框 弹出框中图片放大缩小 ESC隐藏弹出框
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
list-style: none;
}
html,
body {
width: 100%;
height: 100%;
}
.box {
width: 400px;
height: 225px;
margin: 100px;
position: relative;
display: flex;
}
.list {
display: flex;
flex-direction: column;
align-items: center;
width: 110px;
border: 1px solid bisque;
}
.list li {
display: inline-block;
width: 100px;
}
.list li:hover {
cursor: pointer;
}
.list li img {
width: 100px;
object-fit: cover;
}
.imgBox {
margin-left: 10px;
width: 300px;
height: 220px;
border: 1px solid rgb(136, 131, 125);
position: relative;
}
.imgBox .shade {
width: 200px;
height: 120px;
background: rgba(255, 255, 0, 0.4);
position: absolute;
top: 0;
left: 0;
cursor: move;
}
.imgBox img