Advertisement
tirabytes

HTML: Fullscreen slideshow

Jun 13th, 2019
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style>
  4. #slideshow { position:relative;}
  5. #slideshow img { position:absolute; max-width:100% }
  6. .js #slideshow img { opacity:0 }
  7. .js #slideshow .show, #slideshow .show { opacity:1; #-webkit-animation:fadetoblack 1s; #animation:fadetoblack 1s }
  8. @-webkit-keyframes fadetoblack {
  9. 0% { opacity:0 }
  10. 25% { opacity:1 }
  11. 75% { opacity:1 }
  12. 100% { opacity:0 }
  13. }
  14. @keyframes fadetoblack {
  15. 0% { opacity:0 }
  16. 25% { opacity:1 }
  17. 75% { opacity:1 }
  18. 100% { opacity:0 }
  19. }
  20. </style>
  21. </head>
  22. <body style="margin: 0;">
  23.  
  24. <div id="slideshow">
  25. <?php
  26. $imgs = glob('../location/*.{jpg,jpeg,png,JPG,JPEG,PNG}', GLOB_BRACE);
  27. foreach ($imgs as $img) {
  28. echo "<img src='$img' alt='' />\n";
  29. }
  30. ?>
  31. </div>
  32.  
  33. <script>
  34. document.documentElement.className = 'js';
  35. var slides = document.getElementById('slideshow').getElementsByTagName('img');
  36. function slideShow(i){
  37. slides[i].className = '';
  38. if(i == slides.length -1){ slides[0].className = 'show'; i = -1; }
  39. if(i > -1 ){ slides[i+1].className = 'show'; }
  40. setTimeout(function(){ slideShow(++i % slides.length) }, 15000);
  41. }
  42. setTimeout(function(){ slides[0].className = 'show'; }, 1);
  43. setTimeout(function(){ slideShow(0) }, 15000);
  44. </script>
  45.  
  46. </body>
  47. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement