Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Responsive breakpoints not working for slick slider

I have implemented slick slider which works fine without resizing the browser. But when I resize the browser to 1024 then the responsive breakpoint settings doesn't work.

Jquery--

$('.slider').slick({
  centerMode: true,
  slidesToShow: 1,
  slidesToScroll: 1,
  dots: true,
  infinite: true,
  cssEase: 'linear',
  variableWidth: true,
  variableHeight: true,
  mobileFirst: true,
  responsive: [{
    breakpoint: 1024,
    settings: {
      slidesToShow: 4,
      slidesToScroll: 1,
      centerMode: false
    }
  }]
});

Demo -- https://jsfiddle.net/squidraj/hn7xsa4y/4/

Any help is highly appreciated.

like image 471
Prithviraj Mitra Avatar asked Feb 06 '17 21:02

Prithviraj Mitra


People also ask

Is slick slider responsive?

Fully responsive. Scales with its container. Uses CSS3 when available. Fully functional when not.

What is slider breakpoint?

Breakpoints are the pixel values where Smart Slider changes to show a different layout. For example, you can use breakpoints to make the slider switch to tablet view below 1199px screen width. Breakpoints in Smart Slider based on both the width and height of the browser where the slider displays.

How do slick breakpoints work?

The breakpoints refer to the screen width to trigger the logic of the following settings at. Specifically, they will trigger up to the specified value (in pixels). In your above example, this correlates to the following: 480px and narrower: 1 slide is shown.

What is carousel in slick?

The carousel is a slideshow for cycling through a series of content, built with CSS 3D transforms and a bit of JavaScript. It works with a series of images, text, or custom markup. It also includes support for previous/next controls and indicators. Official documentation.


2 Answers

Add this settings to your code;

$(".slides").slick({
    autoplay:true,
    mobileFirst:true,//add this one
}
like image 115
Shady Kip Avatar answered Sep 18 '22 12:09

Shady Kip


Add slidesToShow and slidesToScroll option in each breakpoint.

 {
  breakpoint: 786,
    settings: {
              slidesToShow: 3,
              slidesToScroll: 1,
              }
 },
 {
  breakpoint: 568,
    settings: {
              slidesToShow: 2,
              slidesToScroll: 1
            }
  }
like image 21
Soumitra Sarkar Avatar answered Sep 20 '22 12:09

Soumitra Sarkar