Basic Photo Scroll Widget

 Here’s a simple code for a clickable photo slide show display with captions :) 

Steps below & editable code at bottom of page :)

Steps on how to add a widget code ——> Widget Tutorial


Adding Your Photos

How to convert your photos into html code to add to widget code to to Catbox

Click here —->Catbox
Upload your file and copy the https link created


Go back to your widget code and paste your photo link in the spaces that say : "YOUR_IMAGE_URL_1" 
But make sure to paste within the quotations 

Changing the colors of widget : 


Copy your color code and paste within the editable widget colors. The section of the widget code you can edit colors will look like this:

/* --- CONFIGURATION SECTION: EDIT COLORS HERE --- */
:root {
  --frame-color: #ffffff;      /* EDIT THIS hex code to change your frame color */
  --frame-border: #cccccc;     /* EDIT THIS to change the thin outline color */
  --caption-bg: #f9f9f9;       /* EDIT THIS to change the caption box background color */
  --arrow-color: #333333;      /* EDIT THIS to change the arrow button icon color */
}

Paste color code number after the “#”

——————————————————-

Copy and paste code below to edit :) 
★★★★★★★★★★★★★★★


<!-- START PHOTO FRAME & CAPTION CAROUSEL WITH ARROWS -->
<div class="custom-carousel-wrapper" style="max-width: 500px;"> <!-- Edit overall width here -->
  
  <!-- THE WIDGET CONTAINER (Main Frame + Shadow) -->
  <div class="photo-frame-container">
    
    <!-- ARROW BUTTONS -->
    <button class="nav-arrow prev-arrow" onclick="changeSlide(-1)" aria-label="Previous Slide">&#10094;</button>
    <button class="nav-arrow next-arrow" onclick="changeSlide(1)" aria-label="Next Slide">&#10095;</button>
    <!-- SLIDES CONTAINER -->
    <div class="slides-viewport">
           <!-- Add or change image URLs and caption text in the data-caption attributes below -->
      <img class="carousel-img active-photo" 
           src="YOUR_IMAGE_URL_1" 
           data-caption="This is the blurb/caption text for your first photo. Type whatever you want here!">
           
      <img class="carousel-img" style="display:none;" src="YOUR_IMAGE_URL_2" data-caption="Your second photo caption goes here!">
      <img class="carousel-img" style="display:none;" src="YOUR_IMAGE_URL_3" data-caption="Your third photo caption goes here!">
      <img class="carousel-img" style="display:none;" src="YOUR_IMAGE_URL_4" data-caption="Your fourth photo caption goes here!">
    </div>
  </div>
  <!-- POP-UP CAPTION BLURB BOX -->
  <div id="captionBox" class="caption-blurb">
    This is the blurb/caption text for your first photo. Type whatever you want here!
  </div>
  
</div>
<!-- EDITABLE DESIGN ASPECTS -->
<style>
/* --- CONFIGURATION SECTION: EDIT COLORS HERE --- */
:root {
  --frame-color: #ffffff;      /* EDIT THIS hex code to change your frame color */
  --frame-border: #cccccc;     /* EDIT THIS to change the thin outline color */
  --caption-bg: #f9f9f9;       /* EDIT THIS to change the caption box background color */
  --arrow-color: #333333;      /* EDIT THIS to change the arrow button icon color */
}
/* Overall Layout Wrapper */
.custom-carousel-wrapper {
  margin: 20px auto;
  font-family: Arial, sans-serif;
  text-align: center;
}
/* THE BASIC FRAME & DROPSHADOW */
.photo-frame-container {
  position: relative;
  background-color: var(--frame-color);
  padding: 15px;                        /* Frame thickness around the picture */
  border: 1px solid var(--frame-border); /* Thin basic outer border */
  border-radius: 4px;                   /* Standard basic slight rounded corners */
  box-shadow: 0px 8px 24px rgba(0,0,0,0.15); /* Shadow behind the entire widget */
  overflow: hidden;
}
/* Viewport for images */
.slides-viewport {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
/* The Photo inside the frame */
.carousel-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}
/* NAVIGATION ARROWS */
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background-color: rgba(255, 255, 255, 0.8);
  color: var(--arrow-color);
  border: 1px solid var(--frame-border);
  font-size: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background-color 0.2s, opacity 0.2s;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.nav-arrow:hover {
  background-color: rgba(255, 255, 255, 1);
}
.prev-arrow { left: 25px; }
.next-arrow { right: 25px; }
/* THE CAPTION BOX */
.caption-blurb {
  margin-top: 15px;
  padding: 12px 15px;
  background-color: var(--caption-bg);
  border: 1px solid var(--frame-border);
  color: #444444;
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
  border-radius: 4px;
}
</style>
<!-- CODE LOGIC (Do not change) -->
<script>
let currentSlideIndex = 0;
function changeSlide(direction) {
  const images = document.querySelectorAll('.carousel-img');
  const captionBox = document.getElementById('captionBox');
  
  // Hide current image
  images[currentSlideIndex].style.display = 'none';
  images[currentSlideIndex].classList.remove('active-photo');
  
  // Move to next or previous slide index safely
  currentSlideIndex += direction;
  if (currentSlideIndex >= images.length) {
    currentSlideIndex = 0;
  } else if (currentSlideIndex < 0) {
    currentSlideIndex = images.length - 1;
  }
  
  // Show new image
  images[currentSlideIndex].style.display = 'block';
  images[currentSlideIndex].classList.add('active-photo');
  
  // Pull the text blurb from data-caption attribute and display it
  const newCaption = images[currentSlideIndex].getAttribute('data-caption');
  captionBox.innerHTML = newCaption;
}
</script>
<!-- END PHOTO FRAME & CAPTION CAROUSEL -->

No comments:

Post a Comment

 ꧁October꧂ Took the month of October off from socials and most online activities to focus on my favorite month of the year:) ♡︎  “ life move...