Hi Guys,
So i am trying to add an automatic slideshow on my home page through a block but cant get the javascript to work.
Any ideas on how I can get this to work???
Kind Regards
asikuy
Tue, 04/28/2020 - 17:45
automatic slideshow
usually those slideshows require a library to be installed.. which one are you using? how are you putting up the slideshow?
Okay so this is how i am trying to the add the code.
I create a block and then add the html in below. 1 / 3 Caption Text 2 / 3 Caption Two 3 / 3 Caption Three
Then i add the css through the appearance settings
* {box-sizing: border-box;}
body {font-family: Verdana, sans-serif;}
.mySlides {display: none;}
img {vertical-align: middle;}
/* Slideshow container */
.slideshow-container { max-width: 1000px; position: relative; margin: auto;
}
/* Caption text */
.text { color: #f2f2f2; font-size: 15px; padding: 8px 12px; position: absolute; bottom: 8px; width: 100%; text-align: center;
}
/* Number text (1/3 etc) */
.numbertext { color: #f2f2f2; font-size: 12px; padding: 8px 12px; position: absolute; top: 0;
}
/* The dots/bullets/indicators */
.dot { height: 15px; width: 15px; margin: 0 2px; background-color: #bbb; border-radius: 50%; display: inline-block; transition: background-color 0.6s ease;
}
.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}
}
And here is the javascript below, i tried adding it in the block and various of the template files but still no luck
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
}
PLEASE HELP !!!
automatic slideshow
In reply to automatic slideshow by asikuy
Slideshow