-
-
Save itsalb3rt/25435fbf6622b656bb219c57d225a38e to your computer and use it in GitHub Desktop.
simple vanilla javascript slider using css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img class="slide_image" src="some_url_img.jpg" alt="imagen login1"> | |
<img class="slide_image" src="some_url_img.jpg" alt="imagen login2"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.slide_image{ | |
transition: opacity 1s ease-in; | |
} | |
.slide_image + .slide_image { opacity: 0; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var current = 0, | |
slides = document.querySelectorAll(".slide_image"); | |
setInterval(function() { | |
for (var i = 0; i < slides.length; i++) { | |
slides[i].style.opacity = 0; | |
slides[i].style.display = 'none'; | |
} | |
current = (current != slides.length - 1) ? current + 1 : 0; | |
slides[current].style.opacity = 1; | |
slides[current].style.display = 'block'; | |
}, 6000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment