carouFredSel responsive height

前端 未结 14 705
一整个雨季
一整个雨季 2021-01-30 11:46

i am having height problems of my responsive carousel using carouFredSel.

since the images are responsive and the carousel is also set to responsive.

It still ad

14条回答
  •  南方客
    南方客 (楼主)
    2021-01-30 12:28

    Pierre's answer almost works, except it doesn't check for the tallest slide, it checks for the first slide's height. In my slide show, the 5th slide in was taller, and wound up getting cut off.

    However, after tinkering, I found that playing with the configuration on resize forces the correct height! So, as an alternative, here's that function, turning the debug on.

    var carousel = $("#swiper");
    
    carousel.carouFredSel({
      width: "100%",
      height: "auto",
      responsive: true,
      auto: true,
      scroll: {
        items: 1,
        fx: 'scroll'
      },
      duration: 1000,
      swipe: {
        onTouch: true,
        onMouse: true
      },
      items: {
        visible: {
          min: 4,
          max: 4
        }
      },
      onCreate: function () {
        $(window).on('resize', function () {
          carousel.trigger('configuration', ['debug', false, true]);
        }).trigger('resize');
      }
    });​
    

提交回复
热议问题