1 在图片上设置点击事件
<img src="../../static/assets/images/qr-code.jpg" style="cursor:zoom-in" onclick="imgcli(this)" th:src="${'/xjbswlUpload/'+banner.imgurl}" />
2 在body下添加一个 用来显示图片得域
<body class="layui-anim layui-anim-up" style="width: 100%">
<div id="divimg" style="cursor:zoom-out;background: rgba(0,0,0,.6);width:100%;height:100%;position: absolute;z-index: 9999;left: 0;top: 0;display: none">
<img style="width: 800px;left: 50%;top:50%;margin-left: -400px;position: absolute;">
</div>
3 js 方法如下:
$('#divimg').click(function(){$(this).fadeOut(200)})
function imgcli(obj){
console.log($(obj).attr("src"))
$('#divimg').fadeIn(200);
$('#divimg img').attr('src',$(obj).attr("src"));
$('#divimg img').css("margin-top","-"+$('#divimg img').height()/2+"px")
}