211-slides-per-group-skip.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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: 100%;
  32. height: 100%;
  33. }
  34. .swiper-slide {
  35. display: flex;
  36. flex-direction: column;
  37. align-items: center;
  38. justify-content: center;
  39. position: relative;
  40. }
  41. .swiper-slide img {
  42. display: block;
  43. width: 100%;
  44. }
  45. @media only screen and (min-width: 769px) {
  46. .swiper-slide:first-child {
  47. transition: transform 100ms;
  48. }
  49. .swiper-slide:first-child img {
  50. transition: box-shadow 500ms;
  51. }
  52. .swiper-slide.swiper-slide-active:first-child {
  53. transform: translateX(50%);
  54. z-index: 2;
  55. }
  56. .swiper-slide.swiper-slide-active:first-child img {
  57. box-shadow: 0px 32px 80px rgba(0, 0, 0, 0.35);
  58. }
  59. .swiper-slide:nth-child(2) {
  60. transition: transform 100ms;
  61. }
  62. .swiper-slide.swiper-slide-next:nth-child(2) {
  63. transform: translateX(55%);
  64. z-index: 1;
  65. }
  66. .swiper[dir="rtl"] .swiper-slide.swiper-slide-active:first-child {
  67. transform: translateX(-50%);
  68. }
  69. .swiper[dir="rtl"] .swiper-slide.swiper-slide-next:nth-child(2) {
  70. transform: translateX(-55%);
  71. }
  72. }
  73. </style>
  74. </head>
  75. <body>
  76. <!-- Swiper -->
  77. <div class="swiper mySwiper">
  78. <div class="swiper-wrapper">
  79. <div class="swiper-slide">
  80. <img
  81. src="./images/nature-1.jpg"
  82. />
  83. </div>
  84. <div class="swiper-slide">
  85. <img
  86. src="./images/nature-2.jpg"
  87. />
  88. </div>
  89. <div class="swiper-slide">
  90. <img
  91. src="./images/nature-3.jpg"
  92. />
  93. </div>
  94. <div class="swiper-slide">
  95. <img
  96. src="./images/nature-4.jpg"
  97. />
  98. </div>
  99. <div class="swiper-slide">
  100. <img
  101. src="./images/nature-5.jpg"
  102. />
  103. </div>
  104. <div class="swiper-slide">
  105. <img
  106. src="./images/nature-6.jpg"
  107. />
  108. </div>
  109. <div class="swiper-slide">
  110. <img
  111. src="./images/nature-7.jpg"
  112. />
  113. </div>
  114. <div class="swiper-slide">
  115. <img
  116. src="./images/nature-8.jpg"
  117. />
  118. </div>
  119. <div class="swiper-slide">
  120. <img
  121. src="./images/nature-9.jpg"
  122. />
  123. </div>
  124. </div>
  125. <div class="swiper-button-next"></div>
  126. <div class="swiper-button-prev"></div>
  127. <div class="swiper-scrollbar"></div>
  128. <div class="swiper-pagination"></div>
  129. </div>
  130. <!-- Swiper JS -->
  131. <script src="../swiper-bundle.min.js"></script>
  132. <!-- Initialize Swiper -->
  133. <script>
  134. var swiper = new Swiper(".mySwiper", {
  135. slidesPerView: 1,
  136. centeredSlides: false,
  137. slidesPerGroupSkip: 1,
  138. grabCursor: true,
  139. keyboard: {
  140. enabled: true,
  141. },
  142. breakpoints: {
  143. 769: {
  144. slidesPerView: 2,
  145. slidesPerGroup: 2,
  146. },
  147. },
  148. scrollbar: {
  149. el: ".swiper-scrollbar",
  150. },
  151. navigation: {
  152. nextEl: ".swiper-button-next",
  153. prevEl: ".swiper-button-prev",
  154. },
  155. pagination: {
  156. el: ".swiper-pagination",
  157. clickable: true,
  158. },
  159. });
  160. </script>
  161. </body>
  162. </html>