I would do this with jQuery (and I bet you're using jQuery for your template too :) )

Be sure you're calling the jQuery library in your page, I would recommend to place it just before the </body> tag and BELOW all the scripts.

for example

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- let's call the following div as the POPUP FRAME -->
<div id="popup">

    <!-- and here comes the image -->
    <img src="http://i.imgur.com/cVJrCHU.jpg" alt="popup">

        <!-- Now this is the button which closes the popup-->
        <button id="close">Close button</button>

        <!-- and finally we close the POPUP FRAME-->
        <!-- everything on it will show up within the popup so you can add more things not just an image -->
</div>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script>
//your jquery script here
</script>

</body>
</html>

This will show up a piece of code, if you want to simply show an image, put the id="popup" directly on your <img> tag.

Now, let's move to the example... the code is pretty easy to understand:

//with this first line we're saying: "when the page loads (document is ready) run the following script"
$(document).ready(function () {

    //select the POPUP FRAME and show it
    $("#popup").hide().fadeIn(1000);

    //close the POPUP if the button with id="close" is clicked
    $("#close").on("click", function (e) {
        e.preventDefault();
        $("#popup").fadeOut(1000);
    });

});

The script behaves like this: When the page is loaded, the content inside <div id="popup"> show up, and if the button with id="close" is clicked, then the pop up is hidden. Add whatever you want inside this <div id="popup"> and it will show inside the popup.

The CSS: SUPER IMPORTANT!

/*we need to style the popup with CSS so it is placed as a common popup does*/
    #popup {
            display:none;
            position:absolute;
            margin:0 auto;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 9999;
    }

You can see it working along with the HTML on this live example:

http://jsfiddle.net/Lp9edyg5/1/

Answer from Frondor on Stack Overflow
🌐
Poper
poper.ai › image-to-popup
Free Image To Popup Generator by Poper
• One-click popup generation• Fully customizable settings• Works on any website (HTML, WordPress, Bootstrap, React, jQuery) Image to Popup Generator is an easy-to-use tool that allows you to turn any image into a fully customizable popup ...
🌐
W3Schools
w3schools.com › howto › howto_css_modal_images.asp
How To Create Modal Images
Convert Weight Convert Temperature Convert Length Convert Speed · Get a Developer Job Become a Front-End Dev. Hire Developers ... Learn how to create responsive Modal Images with CSS and JavaScript. A modal is a dialog box/popup window that is displayed on top of the current page.
People also ask

Can I customize the popup?
Yes! You can change size, background, clickability, and more.
🌐
poper.ai
poper.ai › image-to-popup
Free Image To Popup Generator by Poper
Can I add buttons to the popup?
Yes, you can add buttons to the popup! Whether you want a simple call-to-action button or something more advanced, the tool allows you to include interactive buttons that can link to other pages or websites.
🌐
poper.ai
poper.ai › image-to-popup
Free Image To Popup Generator by Poper
Does this work in WordPress?
Yes! You can use this for WordPress image popups with or without plugins.
🌐
poper.ai
poper.ai › image-to-popup
Free Image To Popup Generator by Poper
Top answer
1 of 1
7

I would do this with jQuery (and I bet you're using jQuery for your template too :) )

Be sure you're calling the jQuery library in your page, I would recommend to place it just before the </body> tag and BELOW all the scripts.

for example

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- let's call the following div as the POPUP FRAME -->
<div id="popup">

    <!-- and here comes the image -->
    <img src="http://i.imgur.com/cVJrCHU.jpg" alt="popup">

        <!-- Now this is the button which closes the popup-->
        <button id="close">Close button</button>

        <!-- and finally we close the POPUP FRAME-->
        <!-- everything on it will show up within the popup so you can add more things not just an image -->
</div>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script>
//your jquery script here
</script>

</body>
</html>

This will show up a piece of code, if you want to simply show an image, put the id="popup" directly on your <img> tag.

Now, let's move to the example... the code is pretty easy to understand:

//with this first line we're saying: "when the page loads (document is ready) run the following script"
$(document).ready(function () {

    //select the POPUP FRAME and show it
    $("#popup").hide().fadeIn(1000);

    //close the POPUP if the button with id="close" is clicked
    $("#close").on("click", function (e) {
        e.preventDefault();
        $("#popup").fadeOut(1000);
    });

});

The script behaves like this: When the page is loaded, the content inside <div id="popup"> show up, and if the button with id="close" is clicked, then the pop up is hidden. Add whatever you want inside this <div id="popup"> and it will show inside the popup.

The CSS: SUPER IMPORTANT!

/*we need to style the popup with CSS so it is placed as a common popup does*/
    #popup {
            display:none;
            position:absolute;
            margin:0 auto;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 9999;
    }

You can see it working along with the HTML on this live example:

http://jsfiddle.net/Lp9edyg5/1/

🌐
Poper
poper.ai › guides › how-to-make-a-popup-image-in-html
How To Make a Popup Image in HTML - Poper
May 8, 2025 - Head over to https://www.poper.ai/image-to-popup/ to get started. This is where the magic happens. Just drag and drop the image you want to use for your popup or select it from your files.
🌐
Groupthought
help.groupthought.com › pipeline documentation › tutorials › how to show an image in a pop-up window
How to show an image in a pop-up window - Pipeline Documentation
<a class="image-link" href="https://cdn.shopify.com/s/files/1/2018/8867/files/matteo-paganelli-39971_530x.jpg">Open popup</a> You can add as many links as you like, make sure you use the class " image-link" in order for the pop-up/modal to work. ... These URL's are the full size image. So you may want to use a smaller image by converting:
🌐
W3Schools
w3schools.com › css › css3_images_modal.asp
CSS Responsive Modal Images
CSS Reference CSS Selectors CSS ... PX-EM Converter CSS Colors CSS Color Values CSS Default Values CSS Browser Support ... A modal image gives a user the ability to display a larger version of an image, without navigating away from the current page.
Find elsewhere
🌐
CodePen
codepen.io › Muhnad › pen › dMbXNb
image popup
Minimize HTML Editor · Fold All · Unfold All · <div class="popup"> <img src="http://images.entertainment.ie/images_content/rectangle/620x372/success-kid.jpg"> <img src="https://pbs.twimg.com/media/CX1PAZwVAAANemW.jpg"> <img src="http://images5.fanpop.com/image/photos/30900000/beautiful-pic-different-beautiful-pictures-30958249-1600-1200.jpg"> </div> <div class="show"> <div class="overlay"></div> <div class="img-show"> <span>X</span> <img src=""> </div> </div> <!--End image popup--> !
🌐
Dimsemenov
dimsemenov.com › plugins › magnific-popup
Magnific Popup: Responsive jQuery Lightbox Plugin
Three simple popups with different scaling settings. 1 — fits horizontally and vertically, 2 — only horizontally, 3 — no gaps, zoom animation, close icon in top-right corner. You may put any HTML content in each gallery item and mix content types. In this example lazy-loading of images is enabled for the next image based on move direction.
🌐
DEV Community
dev.to › themodernweb › awesome-image-popup-you-have-never-seen-it-before-4deg
How to make this awesome image popup effect - DEV Community
June 6, 2021 - <!-- popup --> <div class="popup"> <!-- top bar --> <div class="top-bar"> <p class="image-name">img1.png</p> <span class="close-btn"></span> </div> <!-- arrows --> <button class="arrow-btn left-arrow"><img src="img/arrow.png" alt=""></button> <button class="arrow-btn right-arrow"><img src="img/arrow.png" alt=""></button> <!-- image --> <img src="img/img1.png" class="large-image" alt=""> <!-- image-index --> <h1 class="index">01</h1> </div> <div class="gallery"> <div class="gallery-image"> <img src="img/img1.png" alt="" class="image"> </div> <div class="gallery-image"> <img src="img/img2.png" a
🌐
Bqardi
bqardi.dk › tutorials › js › image-popup › index.php
Image Popup
The next two are the title and the image. Simple. At this point you could style the popup to your hearts content by setting the style "display: none;" to "display: block;" temporarily. When done styling, set it back to "display: none;". <div id="popup-background" class="popup-background" style="display: none;"> <div class="popup-content"> <div id="popup-title"></div> <img id="popup-image" class="popup-image"> </div> </div>
🌐
Cloudinary
cloudinary.com › home › mastering javascript image popup
Mastering JavaScript Image Popup | Cloudinary
June 23, 2024 - Finally, an event listener (click event) is added to each image container <div>, which, when clicked, sets the modal element’s display style to “block” to show it, changes modalImg‘s src attribute to the clicked image’s URL and finally changes the captionText‘s inner HTML to the clicked image’s title.
🌐
Websitecodetutorials
websitecodetutorials.com › code › photo-galleries › css-popup-image.php
As Simple As It Gets CSS Popup Image Tutorial
#thumbwrap { margin:75px auto; width:252px; height:252px; } .thumb { float:left; /* must be floated for same cross browser position of larger image */ position:relative; margin:3px; } .thumb img { border:1px solid #000; vertical-align:bottom; } .thumb:hover { border:0; /* IE6 needs this to show large image */ z-index:1; } .thumb span { position:absolute; visibility:hidden; } .thumb:hover span { visibility:visible; top:37px; left:37px; }
🌐
Simplemaps
simplemaps.com › docs › add-images
How to add images to a popup - HTML5/JavaScript Interactive Map Documentation | Simplemaps.com
Craft a line of HTML with an <img> tag whose src contains the url you just saved: <img src="https://simplemaps.com/static/img/frog.png" /> If your image is too big, you can use inline CSS to make it smaller:
🌐
Elfsight
elfsight.com › popup-widget › templates › image-popup
Embed Free Image Popup Template on Your Website
September 24, 2025 - Popup details You can layer elements and construct an infinite array of content blocks: title, text, CTA button, redirect link, coupon, form, image, and video. Also, for an improved visual appeal, you can add gaps, separators, and custom HTML and iFrame fields.
Rating: 5 ​ - ​ 397 votes
🌐
Shoptimized
help.shoptimized.net › en › funnel-buildr › how-to-create-a-clickable-image-popup-2
How to Create a Clickable Image Popup
p-img { padding: 0; } .mfp-img-mobile .mfp-figure:after { top: 0; bottom: 0; } .mfp-img-mobile .mfp-figure small { display: inline; margin-left: 5px; } .mfp-img-mobile .mfp-bottom-bar { background: rgba(0, 0, 0, 0.6); bottom: 0; margin: 0; top: auto; padding: 3px 5px; position: fixed; box-sizing: border-box; } .mfp-img-mobile .mfp-bottom-bar:empty { padding: 0; } .mfp-img-mobile .mfp-counter { right: 5px; top: 3px; } .mfp-img-mobile .mfp-close { top: 0; right: 0; width: 35px; height: 35px; line-height: 35px; background: rgba(0, 0, 0, 0.6); position: fixed; text-align: center; padding: 0; } } @
🌐
W3Schools
www-db.deis.unibo.it › courses › TW › DOCS › w3schools › howto › howto_css_modal_images.asp.html
How To Create Modal Images
HowTo Home Slideshow Google Maps Calendar Animated Buttons Modal Boxes Modal Images JS Animations Progress Bars Tooltips Hover Dropdowns Click Dropdowns Responsive Tables HTML Includes Image Effects Loader Menu Icon Accordion Tabs Contact Chips Pagination Animated Search Top Navigation Fullscreen Navigation Side Navigation Icon Bar Alerts Toggle Switch Scroll Drawing Pricing Table ... Learn how to create responsive Modal Images with CSS and JavaScript. A modal is a dialog box/popup window that is displayed on top of the current page.
🌐
Hashnode
devlawrence.hashnode.dev › how-to-create-an-image-pop-up-gallery
How to create an image pop-up gallery - Dev Lawrence
August 31, 2022 - ... <!DOCTYPE html> <html lang="en"> ... initial-scale=1.0" /> <link rel="stylesheet" href="./css/style.css" /> <title>Image pop up modal</title> <script defer src="./script.js"></script> </head> <body> <div class="con...
🌐
DEV Community
dev.to › sarah_chima › image-popup-on-hover-1kee
Image Popup on hover - DEV Community
October 12, 2018 - I did not know how to do it but ... This technique is placing two images side by side, the thumbnail image(smaller image) and a larger image which will appear when you hover over the thumbnail image....