leftso 1685 0 2019-05-07 11:34:02

logo-cover-bootstrap image viewer 图片放大查看

已封装成为插件欢迎使用及反馈 bootstrap image viewer


bootstrap image viewer 图片放大查看

实现效果:
小图
小图
 
大图
大图
 
<!DOCTYPE html>
<html>
<head>
	<title>bootstrap 图片查看</title>
	<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>

<td>
	<center>
		<img style="height: 100px;width: 100px;" 
		onmouseover="this.style.cursor='pointer';this.style.cursor='hand'" 
		onmouseout="this.style.cursor='default'"  
		src="test.jpg" 
		onclick="javascript:showimage('./test.jpg');" />
	</center>
</td>
  

		<!--放大图的imgModal-->
        <div class="modal fade bs-example-modal-lg text-center" id="imgModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" >
          <div class="modal-dialog modal-lg" style="display: inline-block; width: auto;">
            <div class="modal-content">
             <img  id="imgInModalID"  
			 class="carousel-inner img-responsive img-rounded" 
			 onclick="closeImageViewer()"
			 onmouseover="this.style.cursor='pointer';this.style.cursor='hand'" 
			 onmouseout="this.style.cursor='default'"  
			 />
            </div>
          </div>
        </div>
<script src="https://cdn.bootcss.com/jquery/2.2.0/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</body>
<script type="text/javascript">
	//显示大图    
   function showimage(source)
     {
         $("#imgModal").find("#imgInModalID").attr("src",source);
         $("#imgModal").modal();
     }
	 //关闭
	function closeImageViewer(){
		$("#imgModal").modal('hide');
	}
</script>
</html>