Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- Created by TheiPhoneFan on 2024-03-27 -->
- <!-- Previews 6.0.3, 2022-2024 -->
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <link rel="stylesheet" href="../theme/style.css">
- <link href="https://fonts.googleapis.com/css?family=Roboto:400,300,100,700,900" rel="stylesheet" type="text/css">
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Image Slideshow with Previews</title>
- <style>
- .slideshow-container {
- max-width: 500px;
- position: relative;
- margin: auto;
- }
- .slideshow-container .slideshow-img {
- display: none;
- max-width: 100%;
- height: auto;
- }
- .slideshow-img img {
- border-radius: 16px;
- max-width: 100%;
- }
- .prev, .next {
- cursor: pointer;
- position: absolute;
- top: 50%;
- width: auto;
- margin-top: -22px;
- padding: 16px;
- color: white;
- font-weight: bold;
- font-size: 18px;
- transition: 0.6s ease;
- border-radius: 0 3px 3px 0;
- }
- .prev {
- left: 0;
- }
- .next {
- right: 0;
- }
- .previews-container {
- display: flex;
- justify-content: center;
- margin-top: 10px;
- }
- .preview-img {
- width: 85px;
- height: auto;
- margin: 0 5px;
- cursor: pointer;
- border-radius: 12px;
- }
- .active-preview {
- border: 2px solid #6495ED;
- }
- figcaption {
- text-align: center;
- }
- .image-gallery {
- /* The Gallery That Holds The Images */
- display: flex;
- flex-wrap: wrap;
- justify-content: center;
- gap: 10px;
- }
- .gallery-image {
- /* A pointer cursor will display when you hover over the image */
- cursor: pointer;
- }
- .modal {
- /* The fullscreen popup that shows an expanded view of the image */
- display: none;
- position: fixed;
- padding-top: 50px;
- left: 0;
- top: 0;
- width: 100%;
- height: 100%;
- overflow: auto;
- background-color: rgba(0, 0, 0, 0.9);
- }
- .modal-content {
- /* The content inside of the .modal */
- display: block;
- margin: auto;
- }
- .close {
- /* The close button (x) that can be clicked to close the .modal */
- color: white;
- font-size: 40px;
- position: absolute;
- top: 10px;
- right: 25px;
- cursor: pointer;
- }
- #modalImage {
- /* The image inside the .image-container */
- max-width: 100%;
- width: 450px;
- }
- </style>
- </head>
- <body>
- <div class="slideshow-container" id="slideshow1">
- <div class="slideshow-img" onclick="openModal('../logos/jordans-blog-logo-1.png')">
- <img src="../logos/jordans-blog-logo-1.png">
- <figcaption>Jordan's Blog Logo #1</figcaption>
- </div>
- <div class="slideshow-img">
- <img src="../logos/jordans-blog-logo-2.png" onclick="openModal('../logos/jordans-blog-logo-2.png')">
- <figcaption>Jordan's Blog Logo #2</figcaption>
- </div>
- <div class="slideshow-img">
- <img src="../logos/jordans-blog-logo-3.png" onclick="openModal('../logos/jordans-blog-logo-3.png')">
- <figcaption>Jordan's Blog Logo #3</figcaption>
- </div>
- <div class="slideshow-img">
- <img src="../logos/jordans-blog-logo-4.png" onclick="openModal('../logos/jordans-blog-logo-4.png')">
- <figcaption>Jordan's Blog Logo #4</figcaption>
- </div>
- <a class="prev" onclick="changeSlide('slideshow1', -1)">❮</a>
- <a class="next" onclick="changeSlide('slideshow1', 1)">❯</a>
- </div>
- <div class="previews-container" id="previews1">
- <img class="preview-img" src="../logos/jordans-blog-logo-1.png" onclick="currentSlide('slideshow1', 1)">
- <img class="preview-img" src="../logos/jordans-blog-logo-2.png" onclick="currentSlide('slideshow1', 2)">
- <img class="preview-img" src="../logos/jordans-blog-logo-3.png" onclick="currentSlide('slideshow1', 3)">
- <img class="preview-img" src="../logos/jordans-blog-logo-4.png" onclick="currentSlide('slideshow1', 4)">
- </div>
- <div class="slideshow-container" id="slideshow2" style="margin-top:10px;">
- <div class="slideshow-img">
- <img src="../logos/jordans-blog-6-0.png" onclick="openModal('../logos/jordans-blog-6-0.png')">
- <figcaption>Jordan's Blog 6.0 Logo</figcaption>
- </div>
- <div class="slideshow-img">
- <img src="../logos/jordans-blog-6-1.png" onclick="openModal('../logos/jordans-blog-6-1.png')">
- <figcaption>Jordan's Blog 6.1 Logo</figcaption>
- </div>
- <a class="prev" onclick="changeSlide('slideshow2', -1)">❮</a>
- <a class="next" onclick="changeSlide('slideshow2', 1)">❯</a>
- </div>
- <div class="previews-container" id="previews2">
- <img class="preview-img" src="../logos/jordans-blog-6-0.png" onclick="currentSlide('slideshow2', 1)">
- <img class="preview-img" src="../logos/jordans-blog-6-1.png" onclick="currentSlide('slideshow2', 2)">
- </div>
- <div id="modal" class="modal">
- <span class="close" onclick="closeModal()">×</span>
- <img id="modalImage" class="modal-content" alt="Enlarged Image">
- </div>
- <script>
- function changeSlide(slideshowId, n) {
- showSlides(slideshowId, slideIndex[slideshowId] += n);
- }
- function currentSlide(slideshowId, n) {
- showSlides(slideshowId, slideIndex[slideshowId] = n);
- }
- let slideIndex = {};
- function showSlides(slideshowId, n) {
- let slides = document.getElementById(slideshowId).getElementsByClassName("slideshow-img");
- let previews = document.getElementById('previews' + slideshowId.slice(-1)).getElementsByClassName("preview-img");
- if (!slideIndex[slideshowId]) {
- slideIndex[slideshowId] = 1;
- }
- if (n > slides.length) {
- slideIndex[slideshowId] = 1;
- }
- if (n < 1) {
- slideIndex[slideshowId] = slides.length;
- }
- for (let i = 0; i < slides.length; i++) {
- slides[i].style.display = "none";
- }
- for (let i = 0; i < previews.length; i++) {
- previews[i].classList.remove("active-preview");
- }
- slides[slideIndex[slideshowId] - 1].style.display = "block";
- previews[slideIndex[slideshowId] - 1].classList.add("active-preview");
- }
- showSlides('slideshow1', 1); // Initial call to display the first slide
- showSlides('slideshow2', 1); // Initial call to display the first slide for second slideshow
- // Basic JavaScript for the openModal to work
- function openModal(imageSrc) {
- document.getElementById('modalImage').src = imageSrc;
- document.getElementById('modal').style.display = 'block';
- document.body.classList.add('modal-open'); // Add this line
- document.addEventListener('keydown', function(event) {
- if (event.key === 'Escape') {
- closeModal();
- }
- });
- }
- function closeModal() {
- document.getElementById('modal').style.display = 'none';
- document.body.classList.remove('modal-open'); // Add this line
- document.removeEventListener('keydown', function(event) {
- if (event.key === 'Escape') {
- closeModal();
- }
- });
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement