Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2017
693
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <title>W3.CSS</title>
  4. <meta name="viewport" content="width=device-width, initial-scale=1">
  5. <link rel="stylesheet" href="/lib/w3.css">
  6. <style>
  7. .mySlides {display:none}
  8. </style>
  9. <body>
  10.  
  11. <div class="w3-container">
  12. <h2>Slideshow Indicators</h2>
  13. <p>An example of using buttons to indicate how many slides there are in the slideshow, and which slide the user is currently viewing.</p>
  14. </div>
  15.  
  16. <div class="w3-content" style="max-width:800px">
  17. <img class="mySlides" src="img_nature_wide.jpg" style="width:100%">
  18. <img class="mySlides" src="img_fjords_wide.jpg" style="width:100%">
  19. <img class="mySlides" src="img_mountains_wide.jpg" style="width:100%">
  20. </div>
  21.  
  22. <div class="w3-center">
  23. <div class="w3-section">
  24. <button class="w3-button" onclick="plusDivs(-1)">? Prev</button>
  25. <button class="w3-button" onclick="plusDivs(1)">Next ?</button>
  26. </div>
  27. <button class="w3-button demo" onclick="currentDiv(1)">1</button>
  28. <button class="w3-button demo" onclick="currentDiv(2)">2</button>
  29. <button class="w3-button demo" onclick="currentDiv(3)">3</button>
  30. </div>
  31.  
  32. <script>
  33. var slideIndex = 1;
  34. showDivs(slideIndex);
  35.  
  36. function plusDivs(n) {
  37. showDivs(slideIndex += n);
  38. }
  39.  
  40. function currentDiv(n) {
  41. showDivs(slideIndex = n);
  42. }
  43.  
  44. function showDivs(n) {
  45. var i;
  46. var x = document.getElementsByClassName("mySlides");
  47. var dots = document.getElementsByClassName("demo");
  48. if (n > x.length) {slideIndex = 1}
  49. if (n < 1) {slideIndex = x.length}
  50. for (i = 0; i < x.length; i++) {
  51. x[i].style.display = "none";
  52. }
  53. for (i = 0; i < dots.length; i++) {
  54. dots[i].className = dots[i].className.replace(" w3-red", "");
  55. }
  56. x[slideIndex-1].style.display = "block";
  57. dots[slideIndex-1].className += " w3-red";
  58. }
  59. </script>
  60.  
  61. </body>
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement