最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Slick Slider Mobile Responsiveness - Stack Overflow

programmeradmin1浏览0评论

I am trying to create a responsive slider using Slick on /

On mobile, I only want one slide to show, but 3 are showing. I am trying to use Slick slider's built-in responsive options, but I don't think it is working.

Here is my JS for the slider. Is there something I am doing wrong? I have tried disabling all of my CSS and I am still having this issue.

jQuery(document).ready(function($){


//Sliders//
    $('.slider').slick({
    lazyLoad: 'onDemand',
    centerMode: true,
    infinite: true,
    slidesToShow: 1,
    slidesToScroll: 1,
    dots: true,
    //autoplay: true,
    autoplaySpeed: 6000,
    responsive: [
    {
      breakpoint: 768,
      settings: {
      slidesToShow: 1,
      slidesToScroll: 1
      }
    }
   ]
  });
});

I am trying to create a responsive slider using Slick on https://bhr-caterers.nk-creative./

On mobile, I only want one slide to show, but 3 are showing. I am trying to use Slick slider's built-in responsive options, but I don't think it is working.

Here is my JS for the slider. Is there something I am doing wrong? I have tried disabling all of my CSS and I am still having this issue.

jQuery(document).ready(function($){


//Sliders//
    $('.slider').slick({
    lazyLoad: 'onDemand',
    centerMode: true,
    infinite: true,
    slidesToShow: 1,
    slidesToScroll: 1,
    dots: true,
    //autoplay: true,
    autoplaySpeed: 6000,
    responsive: [
    {
      breakpoint: 768,
      settings: {
      slidesToShow: 1,
      slidesToScroll: 1
      }
    }
   ]
  });
});
Share Improve this question asked Dec 27, 2019 at 2:22 nik218nik218 681 gold badge3 silver badges14 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2
jQuery(document).ready(function($){
//Sliders//
    $('.slider').slick({
    lazyLoad: 'onDemand',
    centerMode: true,
    infinite: true,
    slidesToShow: 1,
    slidesToScroll: 1,
    dots: true,
    //autoplay: true,
    autoplaySpeed: 6000,
    responsive: [
    {
      breakpoint: 768,
      settings: {
      slidesToShow: 1,
      centerMode: false, /* set centerMode to false to show plete slide instead of 3 */
      slidesToScroll: 1
      }
    }
   ]
  });
});

Try this approach.

$('.responsive').slick({
dots: true,
infinite: false,
speed: 300,
slidesToShow: 1, << set default for 1200px onward
slidesToScroll: 1,
responsive: [
{
  breakpoint: 1024, << for desktop width 992px
  settings: {
    slidesToShow: 3,
    slidesToScroll: 3,
    infinite: true,
    dots: true
  }
},
{
  breakpoint: 600, << for tablet
  settings: {
    slidesToShow: 2,
    slidesToScroll: 2
  }
},
{
  breakpoint: 480, << here's your mobile
  settings: {
    slidesToShow: 3,
    slidesToScroll: 3
  }
}]});
发布评论

评论列表(0)

  1. 暂无评论