390-autoheight.html 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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: auto;
  33. }
  34. .swiper-slide {
  35. text-align: center;
  36. font-size: 18px;
  37. background: #fff;
  38. }
  39. .swiper .swiper-slide {
  40. height: 300px;
  41. line-height: 300px;
  42. }
  43. .swiper .swiper-slide:nth-child(2n) {
  44. height: 500px;
  45. line-height: 500px;
  46. }
  47. </style>
  48. </head>
  49. <body>
  50. <!-- Swiper -->
  51. <div class="swiper mySwiper">
  52. <div class="swiper-wrapper">
  53. <div class="swiper-slide">Slide 1</div>
  54. <div class="swiper-slide">Slide 2</div>
  55. <div class="swiper-slide">Slide 3</div>
  56. <div class="swiper-slide">Slide 4</div>
  57. <div class="swiper-slide">Slide 5</div>
  58. <div class="swiper-slide">Slide 6</div>
  59. <div class="swiper-slide">Slide 7</div>
  60. <div class="swiper-slide">Slide 8</div>
  61. <div class="swiper-slide">Slide 9</div>
  62. </div>
  63. <div class="swiper-button-next"></div>
  64. <div class="swiper-button-prev"></div>
  65. <div class="swiper-pagination"></div>
  66. </div>
  67. <!-- Swiper JS -->
  68. <script src="../swiper-bundle.min.js"></script>
  69. <!-- Initialize Swiper -->
  70. <script>
  71. var swiper = new Swiper(".mySwiper", {
  72. autoHeight: true,
  73. spaceBetween: 20,
  74. navigation: {
  75. nextEl: ".swiper-button-next",
  76. prevEl: ".swiper-button-prev",
  77. },
  78. pagination: {
  79. el: ".swiper-pagination",
  80. clickable: true,
  81. },
  82. });
  83. </script>
  84. </body>
  85. </html>