bxslider calculating wrong viewport size on load

前端 未结 6 1498
醉梦人生
醉梦人生 2021-02-07 05:06

Anyway I recently started using bxslider and I\'m having an issue with it.

It seems to calculate its viewport size wrongly on page load, which means it doesn\'t work we

6条回答
  •  一向
    一向 (楼主)
    2021-02-07 06:02

    Found a solution for this safari bug. You have to have the mode of the slider at horizontal (not sure if vertical works too but the fade is not working at all). Then you have to get the height of the first image and pass it to the ".bx-viewport". here is how my script looks like:

    $( "img.Banner" ).attr( "id", "first-slide" );
    $('.bxslider').bxSlider({
      adaptiveHeight: true,
      mode: 'horizontal',
      auto: true
      });
    $("#first-slide").load(function(){
      var height = $(this).height();
       $( ".bx-viewport" ).css( "height", height );
    });
    

提交回复
热议问题