Skip to content

Instantly share code, notes, and snippets.

@nakulkundra
Created September 27, 2022 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nakulkundra/0a2f66ca7b7f10f1c5240323d524136c to your computer and use it in GitHub Desktop.
Save nakulkundra/0a2f66ca7b7f10f1c5240323d524136c to your computer and use it in GitHub Desktop.
image popup
<div class="popup">
<img src="https://exmaxqc.advantagego.com/AdGo.EMAXQC.WebApp/assets/HelpGuide/assets/images/t1_user_profile_01.png">
</div>
<div class="show">
<div class="overlay"></div>
<div class="img-show">
<span><svg id="Cross" viewBox="0 0 1000 1000">
<path d="M200,250l250,250l-250,250l50,50l250,-250l250,250l50,-50l-250,-250l250,-250l-50,-50l-250,250l-250,-250z"></path>
</svg></span>
<img src="">
</div>
</div>
$(function () {
"use strict";
$(".popup img").click(function () {
var $src = $(this).attr("src");
$(".show").fadeIn();
$(".img-show img").attr("src", $src);
});
$("span, .overlay").click(function () {
$(".show").fadeOut();
});
});
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
.show {
z-index: 999;
display: none;
}
.show .overlay {
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.66);
position: absolute;
top: 0;
left: 0;
}
.show .img-show {
background: #fff;
position: absolute;
top: 50%;
left: 50%;
zoom: 1.5;
transform: translate(-50%, -50%);
overflow: auto;
display: block;
}
.img-show span {
position: absolute;
top: 10px;
right: 10px;
z-index: 99;
cursor: pointer;
}
.img-show span svg {
height: 2vh;
}
.img-show img {
}
/*End style*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment