JSFiddle - React, Tailwind, and code Playground
HTML
<div class="col-3 marg">
<img src="https://3dexport.com/items/2015/09/02/394008/163571/dypsis_lutescens_3d_model_c4d_max_obj_fbx_ma_lwo_3ds_3dm_stl_1817928_o.jpg" style="width:50%; height: 500px;" onclick="openModal();currentSlide(1)" class="hover-shadow cursor test">
</div>
<div id="myModal" class="modal">
<span class="close cursor" onclick="closeModal()">×</span>
<div class="modal-content2">
<div class="mySlides">
<div class="numbertext">1 / 1</div>
<img src="https://3dexport.com/items/2015/09/02/394008/163571/dypsis_lutescens_3d_model_c4d_max_obj_fbx_ma_lwo_3ds_3dm_stl_1817928_o.jpg" style="width: 100%; height: auto;">
</div>
<a style="color: red;" class="prev" onclick="plusSlides(-1)">❮</a>
<a style="color: red;" class="next" onclick="plusSlides(1)">❯</a>
</div>
</div>
<script>
function openModal() {
document.getElementById('myModal').style.display = "block";
}
function closeModal() {
document.getElementById('myModal').style.display = "none";
}
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("demo");
var captionText = document.getElementById("caption");
if (n > slides.length) {
slideIndex = 1
}
if (n < 1) {
slideIndex = slides.length
}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex - 1].style.display = "block";
dots[slideIndex - 1].className += " active";
captionText.innerHTML = dots[slideIndex - 1].alt;
}
</script>
CSS
.modal {
display: none;
position: fixed;
z-index: 1;
padding-top: -100px;
left: 0;
top: 0;
width: 100%;
overflow: auto;
background-color: rgb(0, 0, 0);
background-color: rgba(0, 0, 0, 0.4);
}
.modal-content {
position: relative;
background-color: #fefefe;
margin: auto;
padding: 0;
max-width: 1200px;
width: 370px;
}
.close {
color: white;
position: absolute;
top: 10px;
right: 25px;
font-size: 35px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #999;
text-decoration: none;
cursor: pointer;
}
.cursor {
cursor: pointer
}
.prev,
.next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
padding: 16px;
margin-top: -50px;
color: white;
font-weight: bold;
font-size: 20px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
-webkit-user-select: none;
}
.next {
right: 0px;
border-radius: 3px 0 0 3px;
}
.prev:hover,
.next:hover {
background-color: rgba(0, 0, 0, 0.8);
}
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}