I am currently working on creating an automated slideshow that spans the entire page and switches images every 4 seconds. I have set up a codepen for testing purposes, but I am encountering some issues with it. There are 5 images that I am using, and my goal is to have them change at regular intervals if possible. The project utilizes Bootstrap 3 in ASP.NET, but fortunately, it does not cause any conflicts with the slideshow.
var slideIndex = 0;
showSlides();
function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length) {slideIndex = 1}
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";
setTimeout(showSlides, 2000); // Change image every 2 seconds
}
* {box-sizing: border-box;}
body {font-family: Verdana, sans-serif;}
.mySlides {display: none;}
img {}
/* Slideshow container */
.slideshow-container {
position: relative;
margin: auto;
}
.active {
background-color: #717171;
}
/* Fading animation */
.fade {
-webkit-animation-name: fade;
-webkit-animation-duration: 1.5s;
animation-name: fade;
animation-duration: 1.5s;
}
@-webkit-keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
@keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
/* On smaller screens, decrease text size */
@media only screen and (max-width: 300px) {
.text {font-size: 11px}
}
<div style="max-height: 100vh; overflow: hidden;">
<div class="slideshow-container">
<div class="mySlides fade">
<img src="ImageURL1.jpg" style="width:100vw;">
</div>
<div class="mySlides fade">
<img src="ImageURL2.jpg" style="width:100vw;">
</div>
<div class="mySlides fade">
<img src="ImageURL3.jpg" style="width:100vw;">
</div>
<div class="mySlides fade">
<img src="ImageURL4.jpg" style="width:100vw;">
</div>
<div class="mySlides fade">
<img src="ImageURL5.jpg" style="width:100vw;">
</div>
<div class="mySlides fade">
<img src="ImageURL6.jpg" style="width:100vw;">
</div>
</div>
</div>