carouFredSel responsive height

前端 未结 14 832
一整个雨季
一整个雨季 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条回答
  •  Happy的楠姐
    2021-01-30 12:33

    I stumbled upon this issue a while ago; the only solution I found is to resize the container when the browser is being resized. It does the trick but the pedant in me doesn't like it much.

    I only made a reference to the carousel, and added the onCreate function:

    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: onCreate
    });​
    
    function onCreate() {
      $(window).on('resize', onResize).trigger('resize');
    }
    
    function onResize() {
      // Get all the possible height values from the slides
      var heights = $carousel.children().map(function() { return $(this).height(); });
      // Find the max height and set it
      $carousel.parent().add($carousel).height(Math.max.apply(null, heights));
    }
    

    If you are still using this plugin in 2015, then it's time to move on.
    The free version is no longer supported and the commercial version is now a Wordpress plugin. Plus who needs to hack a slider to make it responsive nowadays ?!

提交回复
热议问题