Basic image pop-up plug-in using vanilla JavaScript.
See example here.
You're free to use and modify this plugin in your project under the terms of the Apache 2.0 license.
To use plugin, follow these steps:
-
Clone, download, or simply copy and paste imagePopUp.js and add it as a file in your project directory
-
Add
class="pop-up-img"
to the image element(s) you wish to enlarge in your HTML -
Copy and paste the following and add it to the appropriate section of your HTML (it can technically be added anywhere, but only needs to be added once):
<div class="pop-up-frame">
<button class="pop-up-exit-button" role="button" aria-roledescription="button to exit out of enlarged image">
<span class="cross-one"></span>
<span class="cross-two"></span>
</button>
<img class="zoomed-img" src="">
</div>
-
Add
imagePopUp.js
as a module in your HTML using:<script type="module" src="./your/pathway/here/imagePopUp.js"></script>
-
Copy and paste the rules in
style.css
to your project's CSS file (Exclude the.pop-up-image
rules, make nessesary changes to.zoomed-img
height:
andwidth:
rules to match sizing with your image(s), and make any other style changes to match your project)
Feel free to reach out with any questions, comments, or additions/improvements! 😁