I've modified a W3 schools slideshow template to use text instead of dots, but I'm encountering two issues
1: The first image doesn't load when the page loads. Although using a class ID and setting it to active fixes this issue, it leads to my second problem.
2: When I force the image to load, the text/button for that first slide is not in an active state. The color should be red for active/hover and grey for inactive, yet when the forced image loads, the text remains grey.
Here's the code snippet:
<style>
{box-sizing: border-box}
.mySlides {display: none}
img {vertical-align: middle;}
/* Slideshow container */
.slideshow-container {
max-width: 1000px;
position: relative;
margin: auto;
}
/* Dots/bullets/indicators style */
.dot {
cursor: pointer;
height: auto;
width: auto;
margin: 0 2px;
color: #bbb;
border-radius: 50%;
display: inline-block;
transition: color 0.6s ease;
}
.active, .dot:hover {
color: #cc3333;
}
/* 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}
}
/* Decrease text size on smaller screens */
@media only screen and (max-width: 300px) {
.prev, .next,.text {font-size: 11px}
}
</style>
<script>
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
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";
}
</script>
<div style="border-top: 6px solid #cc3333;padding-bottom: 100px; padding-top: 100px" class="row highlight-phone">
<div class="container">
<div class="vidrow">
<div class="vidcolumn slideshow-container">
<div id="slide1" class="mySlides">
<img src="https://www.w3schools.com/howto/img_nature_wide.jpg" style="width:100%">
</div>
<div class="mySlides">
<img src="img_snow_wide.jpg" style="width:100%">
</div>
<div class="mySlides">
<img src="img_mountains_wide.jpg" style="width:100%">
</div>
</div>
<div class="vidcolumn">
<div class="intro">
<h2 style="text-decoration:overline;text-decoration-color: #cc3333;">How It Works</h2>
<div id="dot" class="dot" onclick="currentSlide(1)">Learning Paths</div>
<br>
<span id="dot" class="dot" onclick="currentSlide(2)">Songs</span>
<br>
<span id="dot" class="dot" onclick="currentSlide(3)">Training</span>
<br>
<br>
<br>
<a class="btn btn-primary btn-lg btn-wi-red btn-pill" role="button" href="#">VIEW DEMO</a>
</div>
</div>
</div>
</div>
</div>
For visual reference, check out the image: Imgur
Any tips on resolving this?