0
I have this code (Internet model) automatic slide transition. I wonder how I would put the effect "Fade".
<img class="mySlides" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSFh65LFf2UPsjvNxBuBISj4C4WC3K9FtKfc1_vcC9pvi_oqWAdgw" style="border-radius:10px; width:515px; height:370px">
<img class="mySlides" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQYpuQvYCQfZEBtvib6zTi69oY0CYmwtQGspxeKuLHJsfpb_8P4QQ" style="border-radius:10px; width:515px; height:370px">
<img class="mySlides" src="https://www.infoescola.com/wp-content/uploads/2012/10/bauru-cidade_748974265-1000x750.jpg" style="border-radius:10px; width:515px; height:370px" >
<script type="text/javascript">
var slideIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
slideIndex++;
if (slideIndex > x.length) {slideIndex = 1}
x[slideIndex-1].style.display = "block";
setTimeout(carousel, 2000); // Change image every 2 seconds
}
</script>
You want a JS answer because you are studying JS and would like to see the code, or a CSS-only answer without needing JS would already suit you?
– hugocsl
This link has a slideshow made only with CSS if you’re interested https://answall.com/questions/288556/bug-no-slideshow-se-ficar-muito-tempo-fora-do-separador/288581#288581
– hugocsl
I have added some explanatory remarks to the code. I hope it will help you understand.
– Sam