Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swiper height auto resize

I have added swiper code in [REMOVED].

my code like here

<div class="swiper-container">
  <div class="swiper-wrapper">
      <!--First Slide-->
      <div class="swiper-slide" id="swiper-slide"> 
            <div class="content-slide">
                content1
            </div>
        </div> 
      </div>
      <!--Second Slide-->
      <div class="swiper-slide" id="swiper-slide"> 
            <div class="content-slide">
                content1
            </div>
        </div> 
      </div>
  </div>
</div>

They have blank space.

Please see image.

I want to remove this space.

like image 805
ryush00 Avatar asked Sep 20 '14 08:09

ryush00


1 Answers

Update:

As passatgt mentioned in the comments for newer versions calculateHeight is replaced with autoHeight, here you can find an example:

var swiper = new Swiper('.swiper-container', {
  autoHeight: true, //enable auto height
  spaceBetween: 20,
  pagination: {
    el: '.swiper-pagination',
    clickable: true,
  },
  navigation: {
    nextEl: '.swiper-button-next',
    prevEl: '.swiper-button-prev',
  },
});

Add calculateHeight:true to swiper definition.

 var tabsSwiper = new Swiper('.swiper-container',{
    speed:300,
    calculateHeight:true,
    onSlideChangeStart: function(){
      $(".tabs li").removeClass('active')
      $(".tabs li").eq(tabsSwiper.activeIndex).addClass('active')  
    }
  })
like image 168
Erfan Avatar answered Sep 21 '22 14:09

Erfan