当前位置:网站首页>Simple picture preview
Simple picture preview
2022-06-12 12:37:00 【Five flower hourglass】
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Simple picture preview </title>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
</head>
<style> .imgDolage {
width: 100%; height: 100%; background: rgba(000, 000, 000, .7); position: fixed; top: 0; left: 0; bottom: 0; z-index: 12; display: flex; justify-content: center; align-items: center; overflow: auto; } .imagesBody {
border: 5px solid #fff; cursor: pointer; height: 90%; } .dis {
display: none !important; } .img-small {
width: 300px; height: 180px; border: 5px solid #333; } </style>
<body>
<img class="img-small" src="https://cn.vuejs.org/images/logo.svg" onclick="imgShow()">
<div class="imgDolage dis">
<img class="imagesBody" src="" alt="">
</div>
</body>
<script> function imgShow() {
// Always point to event bound elements , and Event.target Is the event triggered element . var is = event.currentTarget $('.imgDolage').removeClass('dis') $('.imgDolage img').attr('src', is.getAttribute('src')) } let ActiveImages = false $(".imgDolage").click(function (e) {
let _con = $('.imagesBody'); // Set the target area if (!_con.is(e.target) && _con.has(e.target).length === 0) {
// Click on the area outside the picture , Stow preview $('.imgDolage').addClass('dis') ActiveImages = false } else {
// Click on the image : Zoom in and out if (ActiveImages) {
_con.css('top', '5%') _con.css('height', '90%') ActiveImages = false } else {
_con.css('top', '0%') _con.css('height', 'auto') ActiveImages = true } } }); </script>
</html>

Click the small picture in the upper left corner to open the preview pop-up window , Click the picture in the preview pop-up window to further enlarge , Click again to shrink back to the original size . Click the mask layer area outside the picture to close the preview pop-up window .
边栏推荐
猜你喜欢

Buu question brushing record - 6

【您编码,我修复】WhiteSource正式更名为Mend

JS built in object

Influxdb2.x benchmark tool - influxdb comparisons

Advanced C language -- storage of floating point in memory

Buu question brushing record - 5

数组——二维数组的花式遍历技巧

Problems encountered in installing canvas and errors encountered in running the project

this.$ How to solve the problem when refs is undefined?

Iterator, generator generator details
随机推荐
JS method of exporting DOM as picture
itkMultiResolutionImageRegistrationMethod
C语言进阶篇——万字详解指针和qsort函数
this.$ How to solve the problem when refs is undefined?
Differences and recommended uses of VaR, let and const (interview)
Video speed doubling in PC browser
Typeof and instanceof, how to simulate the implementation of an instanceof? Is there a general detection data type?
Difference between Definition and Declaration
一个ES设置操作引发的“血案”
配准后图像对比函数itk::CheckerBoardImageFilter
恭喜Splashtop 荣获2022年 IT Europa “年度垂直应用解决方案”奖
JS convert string to array object
Advanced C language -- storage of floating point in memory
一个ES设置操作引发的“血案”
NDT registration principle
Difference between Definition and Declaration
拿来就能用的网页动画特效,不来看看?
【Leetcode】637. Layer average of binary tree
Redis的主从复制原理
The advantages of saving pointers when saving objects with vector and the use of reserve