450-watchslidesvisibility.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Swiper demo</title>
  6. <meta
  7. name="viewport"
  8. content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1"
  9. />
  10. <!-- Link Swiper's CSS -->
  11. <link
  12. rel="stylesheet"
  13. href="../swiper-bundle.min.css"
  14. />
  15. <!-- Demo styles -->
  16. <style>
  17. html,
  18. body {
  19. position: relative;
  20. height: 100%;
  21. }
  22. body {
  23. background: #eee;
  24. font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
  25. font-size: 14px;
  26. color: #000;
  27. margin: 0;
  28. padding: 0;
  29. }
  30. .swiper {
  31. width: 800px;
  32. }
  33. .swiper-slide {
  34. height: 300px;
  35. background: #882525;
  36. line-height: 300px;
  37. text-align: center;
  38. }
  39. .swiper-slide:nth-child(2) {
  40. background: #8acc7d;
  41. }
  42. .swiper-slide:nth-child(3) {
  43. background: #b7cc7d;
  44. }
  45. .swiper-slide:nth-child(4) {
  46. background: #9eb75c;
  47. }
  48. .swiper-slide:nth-child(5) {
  49. background: #7da8cc;
  50. }
  51. .swiper-slide:nth-child(6) {
  52. background: #96cc7d;
  53. }
  54. .swiper-slide:nth-child(7) {
  55. background: #cc7dae;
  56. }
  57. </style>
  58. </head>
  59. <body>
  60. <!-- Swiper -->
  61. <h3>
  62. Slider5 is visible when you slide to 2,3, or 4, and slider5 has
  63. "swiper-slide-visible" className
  64. </h3>
  65. <br />
  66. <div class="swiper mySwiper">
  67. <div class="swiper-wrapper">
  68. <div class="swiper-slide">Slide 1</div>
  69. <div class="swiper-slide">Slide 2</div>
  70. <div class="swiper-slide">Slide 3</div>
  71. <div class="swiper-slide">Slide 4</div>
  72. <div class="swiper-slide">Slide 5</div>
  73. <div class="swiper-slide">Slide 6</div>
  74. <div class="swiper-slide">Slide 7</div>
  75. <div class="swiper-slide">Slide 8</div>
  76. <div class="swiper-slide">Slide 9</div>
  77. </div>
  78. </div>
  79. <!-- Swiper JS -->
  80. <script src="../swiper-bundle.min.js"></script>
  81. <!-- Initialize Swiper -->
  82. <script>
  83. var swiper = new Swiper(".mySwiper", {
  84. watchSlidesProgress: true,
  85. slidesPerView: 3,
  86. });
  87. </script>
  88. </body>
  89. </html>