Hey guys, I need assistance. I created this simple booking form website, but I'm having issues with aligning the slider images. The images are coming scattered.
Video link: https://youtube.com/shorts/a4-TE9yihd4?feature=share
SEE THE HTML, JavaScript, AND CSS CODE FOR THIS SECTION
**HTML**
<section id="home">
<div class="slider">
<img src="imgs/banner2.jpg" alt="Banner 1">
<img src="imgs/banner2.jpg" alt="Banner 1">
<img src="imgs/banner2.jpg" alt="Banner 1">
</div>
</section>
**CSS**
.slider-container {
display: flex;
overflow-x: scroll;
scroll-snap-type: x mandatory;
}
.slider-image {
flex: 0 0 100%;
scroll-snap-align: start;
}
.slider-image img {
width: 100%;
position: inline;
height: auto;
}
JavaScript
// Function to change the slider image
function changeSliderImage() {
images[currentImageIndex].classList.remove("active");
currentImageIndex = (currentImageIndex + 1) % images.length;
images[currentImageIndex].classList.add("active");
}
// Change the slider image every 3 seconds
Top comments (1)
The classes (or lack thereof) in your HTML don't match your CSS, and your Javascript is incomplete.