I really can't get this to work.. I want the images to fade in a bit. Found a lot suggesting to do this by opacity transition.. but I just can't figure it out. Can you help me please?
I found out how to address the opacity in the javascript, but the css won't affect it. Read somewhere to delete display:none and block but then the images are gone. I'm sure I miss something fundamental. But after about 6 hours now I thought maybe one of you pros can help me. Unfortunately I am not.
Thanks in advance!
David
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function currentDiv(n) {
showDivs(slideIndex = n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("demo");
if (n > x.length) {
slideIndex = 1
}
if (n < 1) {
slideIndex = x.length
}
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" w3-white", "");
}
x[slideIndex - 1].style.display = "block"
dots[slideIndex - 1].className += " w3-white";
}
document.getElementById("slider-wrapper").style.opacity = 1;
#slider-wrapper {
transition: opacity 2s;
}
<div class="w3-content w3-display-container">
<div id="slider-wrapper">
<img id="zupfinstrumente" class="centerscreen mySlides slidepos" src="img1.jpg" alt="xy">
<img id="ueber-mich" class="centerscreen mySlides slidepos" src="img2.jpg" alt="xy">
<img id="streichinstrumente" class="centerscreen mySlides slidepos" src="img3.jpg" alt="xy"></div>
<div class="w3-center w3-container w3-section w3-large w3-text-white centerscreen badgepos">
<span class="w3-badge demo w3-border w3-transparent w3-hover-white" onclick="currentDiv(1)"></span>
<span class="w3-badge demo w3-border w3-transparent w3-hover-white" onclick="currentDiv(2)"></span>
<span class="w3-badge demo w3-border w3-transparent w3-hover-white" onclick="currentDiv(3)"></span>
</div>
<container id="buttons" class="centerscreen">
<div id="navarrow-left" class="w3-left w3-hover-text-black btn" onclick="plusDivs(-1)">❮</div>
<div id="navarrow-right" class="w3-right w3-hover-text-black btn" onclick="plusDivs(1)">❯</div>
</container>
</div>