首先我们分析一下整个案例
1.鼠标经过小图片盒子时黄色的遮挡层和大图片盒子显示,离开时隐藏
2.黄色的遮挡层跟随鼠标功能。
3.移动黄色遮挡层,大图片跟随移动功能。
html骨架和css:
<style>
.preview_img {
position: relative;
height: 400px;
width: 400px;
border: 1px solid #ccc;
}
.mask {
display: none;
position: absolute;
top: 0;
left: 0;
width: 300px;
height: 300px;
background-color: #FEDE4F;
opacity: .5;
border: 1px solid #ccc;
cursor: move;
}
.big img {
position: absolute;
top: 0;
left: 0;
}
.big {
display: none;
position: absolute;
left: 410px;
top: 0;
width: 500px;
height: 500px;
border: 1px solid #ccc;
overflow: hidden;
}
</style>
<body>
<div class="preview_img">
<img src