<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<!doctype html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link href="https://cdn.bootcss.com/bootstrap-table/1.11.1/bootstrap-table.min.css" rel="stylesheet">
<style type="text/css">
.mask-layer {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 2020;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.mask-layer > div {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.mask-layer-black {
width: 100%;
height: 100%;
background: #000;
opacity: .85;
position: absolute;
top: 0;
left: 0;
}
.mask-layer-container {
min-width: 780px;
max-width: 1260px;
height: 75%;
background: #fff;
margin: 10px auto;
z-index: 2030;
padding: 0 10px;
border-radius: 10px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.mask-layer-toolbar {
min-width: 780px;
max-width: 1260px;
height: 10%;
<!-- background: #fff; -->
margin: 10px auto;
z-index: 2030;
padding: 0 10px;
border-radius: 10px;
position: absolute;
top: 80%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.mask-layer-container-operate {
height: 0%;
padding: 10px 0;
text-align: center;
border-bottom: solid 1px #ddd;
}
.mask-layer-imgbox {
height: 97%;
overflow: hidden;
position: relative;
margin-top: 10px;
}
.mask-layer-imgbox > p {
position: absolute;
cursor: move;
transform-origin: center;
-webkit-transform-origin: center;
-moz-transform-origin: center;
-ms-transform-origin: center;
-o-transform-origin: center;
height: 100%;
padding: 0;
-webkit-margin-before: 0;
-webkit-margin-after: 0;
cursor: move;
left: 0;
top: 0;
}
.mask-layer-imgboxp > p > img {
display: inline-block;
vertical-align: middle;
cursor: move;
}
.mask-prev-next {
<!-- min-width: 780px; -->
<!-- max-width: 1260px; -->
<!-- height: 10%; -->
<!-- background: #fff; -->
margin: 10px auto;
z-index: 2030;
padding: 0 10px;
border-radius: 10px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
/*按钮样式*/
.btn-default-styles {
display: inline-block;
padding: 5px 10px;
margin-bottom: 0;
font-size: 14px;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
background: #8C85E6;
color: #fff;
border: solid 1px #8C85E6;
border-radius: 4px;
}
.btn-default-styles:focus {
outline: none;
}
.btn-default-styles:hover {
background: #8078e3;
animation: anniu 1s infinite;
}
.btn-default-styles:active {
box-shadow: 0 2px 3px rgba(0, 0, 0, .2) inset;
}
.btn-circle {
display: inline-block;
padding: 5px 10px;
margin-bottom: 0;
font-size: 50px;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
background:rgba(255, 255, 255, 0.9) none repeat scroll 0 0 !important;
color: #fff;
border: solid 1px rgba(255, 255, 255, 0.9);
width: 100px;
height: 100px;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 50px;
}
.btn-circle:focus {
outline: none;
}
.btn-circle:hover {
background: #8078e3;
animation: anniu 1s infinite;
}
.btn-circle:active {
box-shadow: 0 2px 3px rgba(0, 0, 0, .2) inset;
}
</style>
<title>结果查看</title>
</head>
<body>
<div class="container">
<div class="row-fluid">
<div class="span12">
<h4>结果查看</h4>
<table data-toggle="table">
<thead>
<tr>
<th>图片编号</th>
<th>鸟巢检测</th>
<th>绝缘子检测</th>
<th>断股检测</th>
<th>散股检测</th>
</tr>
</thead>
<tbody>
<tr>
<td><img modal="zoomImg" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1516941358883&di=c57cbed7f3fbb5b40bcf5ec6cf5458bb&imgtype=0&src=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F503d269759ee3d6db032f61b48166d224e4ade6e.jpg" height="50px">Img_0001</img></td>
<td>95%</td>
<td>0%</td>
<td>0%</td>
<td>0%</td>
</tr>
<tr>
<td><img modal="zoomImg" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1516941358882&di=b3896849d3dc6dabc6045415b4846198&imgtype=0&src=http%3A%2F%2Fa.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F500fd9f9d72a6059f550a1832334349b023bbae3.jpg" height="50px">Img_0002</img></td>
<td>0%</td>
<td>80%</td>
<td>0%</td>
<td>0%</td>
</tr>
<tr>
<td><img modal="zoomImg" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1516941358882&di=641ace84fcfc37a8ae2edc86a51a56ba&imgtype=0&src=http%3A%2F%2Fd.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fa044ad345982b2b713b5ad7d3aadcbef76099b65.jpg" height="50px">Img_0003</img></td>
<td>0%</td>
<td>85%</td>
<td>0%</td>
<td>0%</td>
</tr>
<tr>
<td><img modal="zoomImg" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1516941358882&di=eb6aa6892359095598b32ab517fdcf49&imgtype=0&src=http%3A%2F%2Fe.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F500fd9f9d72a6059099ccd5a2334349b023bbae5.jpg" height="50px">...</img></td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="https://cdn.bootcss.com/bootstrap-table/1.11.1/bootstrap-table.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap-table/1.11.1/locale/bootstrap-table-zh-CN.min.js"></script>
<script>
$(function () {
var len = $("img[modal='zoomImg']").length;
var arrPic = new Array(); //定义一个数组
for (var i = 0; i < len; i++) {
arrPic[i] = $("img[modal='zoomImg']").eq(i).prop("src"); //将所有img路径存储到数组中
}
$("img[modal='zoomImg']").each(function () {
$(this).on("click", function () {
//给body添加弹出层的html
$("body").append(
"<div class=\"mask-layer\">" +
" <div class=\"mask-prev-next\" style=\"width: -webkit-fill-available;\">" +
" <button class=\"mask-prev btn-circle\" style=\"float: left\"> ◁ </button>" +
" <button class=\"mask-next btn-circle\" style=\"float: right\"> ▷ </button>" +
" </div>" +
" <div class=\"mask-layer-black\"></div>" +
" <div class=\"mask-layer-container\">" +
" <div class=\"mask-layer-imgbox auto-img-center\"></div>" +
" </div>" +
" <div class=\"mask-layer-toolbar\">" +
" <div class=\"mask-layer-container-operate\">" +
" <button class=\"mask-out btn-default-styles\">放大</button>" +
" <button class=\"mask-in btn-default-styles\">缩小</button>" +
" <button class=\"mask-close btn-default-styles\">关闭</button>" +
" </div>" +
" </div>" +
"</div>"
);
var img_index = $("img[modal='zoomImg']").index(this);//获取点击的索引值
var num = img_index;
function showImg() {
$(".mask-layer-imgbox").append("<p><img src=\"\" alt=\"\" ></p>");
$(".mask-layer-imgbox img").prop("src", arrPic[num]); //给弹出框的Img赋值
//图片居中显示
var box_width = $(".auto-img-center").width(); //图片盒子宽度
var box_height = $(".auto-img-center").height();//图片高度高度
var initial_width = $(".auto-img-center img").width();//初始图片宽度
var initial_height = $(".auto-img-center img").height();//初始图片高度
$(".mask-layer-container").css("width", initial_width);
$(".mask-layer-container").css("height", initial_height);
<!-- if (initial_width > initial_height) { -->
<!-- $(".auto-img-center img").css("width", box_width); -->
<!-- var last_imgHeight = $(".auto-img-center img").height(); -->
<!-- $(".auto-img-center img").css("margin-top", -(last_imgHeight - box_height) / 2); -->
<!-- } else { -->
<!-- $(".auto-img-center img").css("height", box_height); -->
<!-- var last_imgWidth = $(".auto-img-center img").width(); -->
<!-- $(".auto-img-center img").css("margin-left", -(last_imgWidth - box_width) / 2); -->
<!-- } -->
//缩放 放大
var zoom_n = 1;
$(".mask-out").click(function () {
zoom_n += 0.1;
$(".mask-layer-imgbox img").css({
"transform": "scale(" + zoom_n + ")",
"-moz-transform": "scale(" + zoom_n + ")",
"-ms-transform": "scale(" + zoom_n + ")",
"-o-transform": "scale(" + zoom_n + ")",
"-webkit-transform": "scale(" + zoom_n + ")"
});
});
//缩放 缩小
$(".mask-in").click(function () {
zoom_n -= 0.1;
zoom_n = zoom_n <= 0.1 ? 0.1 : zoom_n;
$(".mask-layer-imgbox img").css({
"transform": "scale(" + zoom_n + ")",
"-moz-transform": "scale(" + zoom_n + ")",
"-ms-transform": "scale(" + zoom_n + ")",
"-o-transform": "scale(" + zoom_n + ")",
"-webkit-transform": "scale(" + zoom_n + ")"
});
});
//关闭
$(".mask-close").click(function () {
$(".mask-layer").remove();
});
$(".mask-layer-black").click(function () {
$(".mask-layer").remove();
});
}
showImg();
//下一张
$(".mask-next").on("click", function () {
$(".mask-layer-imgbox p img").remove();
num++;
if (num == len) {
num = 0;
}
showImg();
});
//上一张
$(".mask-prev").on("click", function () {
$(".mask-layer-imgbox p img").remove();
num--;
if (num == -1) {
num = len - 1;
}
showImg();
});
})
});
});
</script>
</body>
</html>