關於swiper的tab(選項卡)中設置了autoHeight沒有效果解決

autoHeight屬性使用看官網的示例:https://www.swiper.com.cn/api/parameters/294.htmljavascript

swiper的選項卡結構查看:https://www.swiper.com.cn/demo/indexsample/html

swiper的tab的通常DOM節點爲:java

<body>api

     <div class="tabs">app

  <a href="#" class="active">選項卡1</a>ide

  <a href="#" class="active">選項卡2</a>spa

  ...htm

    </div>ip

   <div class="swiper-contianer" id="container"> <!--外層容器一點要加上swiper-container類,不然autoHeight屬性沒有用--->swiper

           <div class="swiper-wrapper">

                <div class="swiper-silde"></div>

      <div class="swiper-silde"></div>

      ...

    </div>

 </div>

   <script type="text/javascript">

           var swiper = new Swiper('#container', {

    autoHeight: true, //將autoHeight設置爲true,則swiper-containe容器,swiper-warpper的高度將會隨swiper-slide的高度而變化,自適應高度

      });

   </script>

</body>

相關文章
相關標籤/搜索