Bootstrap 5 Image Gallery with modal Responsive
Download this project Click Here
HTML Code
Image Gallery - Bootstrap 5
JS Code
document.addEventListener("click",function (e){ if(e.target.classList.contains("gallery-item")){ const src = e.target.getAttribute("src"); document.querySelector(".modal-img").src = src; const myModal = new bootstrap.Modal(document.getElementById('gallery-modal')); myModal.show(); } })
CSS Code
img{ max-width: 100%; } .gallery{ background-color: #dbddf1; padding: 80px 0; } .gallery img{ background-color: #ffffff; padding: 15px; width: 100%; box-shadow: 0 0 15px rgba(0,0,0,0.3); cursor: pointer; } #gallery-modal .modal-img{ width: 100%; }