点击图片放大可拖拽
<div>
<ul>
<li>
<img class="comment_pics" width="50px" height="50px" src="img/ez.jpeg" />
<p>号牌号码<span>豫Areceived</span></p>
<p>号牌号码<span>豫Areceived</span></p>
<p>号牌号码<span>豫Areceived</span></p>
</li>
</ul>
</div>
<div class="bg">
<div class="oce" style="position: absolute;left: 30%;top: 25%;">
<img class="bgImg" style="max-width: 100%; max-height: 100%;" src="">
</div>
</div>
ul{
width: 100%;
list-style: none;
display: flex;
justify-content: space-around;
}
li{
width: 19%;
height: 200px;
margin: 10px;
overflow-y: auto;
border: 1px solid gainsboro;
text-align: center;
padding: 10px;
overflow: -moz-scrollbars-none;
-ms-overflow-style: none;
}
li::-webkit-scrollbar {width: 0 !important;}
li > img{
width: 90%;
height: 50%;
}
.bg{
position: fixed;
left: 0;
top: 0;
background: rgba(0,0,0,0.6);
width: 100%;
height: 100%;
display: none;
-moz-user-select:none;
-ms-user-select: none;
-webkit-user-select: none;
user-select: none;
}
.oce{
width: 40%;
height: 60%;
}
.oce > img{
width: 100%;
height: 100%;
}
var Inimg;
$("li>img").click(function(even) {
console.log($(this)[0].src);
Inimg = $(this)[0].src;
$('.bgImg').attr('src', Inimg);
$(".bg").css('display', "block");
return false;
})
$(".bg").dblclick(function(even) {
$(this).css('display', 'none');
$('.bgImg').attr('src', '');
$(".oce").css({
"left": "30%",
"top": "25%"
});
return false;
})
$(".oce").mousedown(function(event) {
if (event.button == 0) {
gapX = event.clientX - $(this).offset().left;
gapY = event.clientY - $(this).offset().top;
console.log(gapX);
$(document).bind("mousemove", move);
$(document).bind("mouseup", stop);
}
return false;
});
function move(event) {
$(".oce").css({
"left": (event.clientX - gapX) + "px",
"top": (event.clientY - gapY) + "px"
});
return false;
}
function stop() {
$(document).unbind("mousemove", move);
$(document).unbind("mouseup", stop);
}