Menu Close

Slick Slider Center Mode With Example

Center mode

Here, we will learn how to create a slick slider with image center mode using html, css and jquery. Follow the below snippet to develope slick slider center mode with the responsive design.

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.5.9/slick.min.css"/>
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.5.9/slick-theme.min.css"/>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css"/>
    <title>Slick Slider Center Mode</title>
</head>
<body>
<div class="main">
  <div class="slider slide-show">
    <div class="img-wish">
        <img src="s1.png" >
        </div>
    <div class="img-wish">
        <img src="s2.png" >
        </div>
    <div class="img-wish">
        <img src="s3.png" >
        </div>
    <div class="img-wish">
        <img src="s4.png" >        
        </div>
    <div class="img-wish">
        <img src="s5.png" >
        </div>
    <div class="img-wish">
        <img src="s6.png" >
        </div>
  </div>
</div>
</body>  
    <script>
        $('.slide-show').slick({
            slidesToShow: 5,
            slidesToScroll: 1,
            centerMode: true,
            arrows: true,
            dots: false,
            speed: 300,
            centerPadding: '20px',
            infinite: true
        });
    </script>
</html> 

CSS:

For better responsive design, create an external stylesheet and add it to the above example.

body{
  background-color: #F5F5FF;
}
.main{
  padding: 70px 0;
}
.slide-show .slick-slide{
  color: #FFF;
  height: 200px;
  margin: 0 15px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0.8);
  transition: all 0.4s ease-in-out;
}
.slide-show .slick-slide,
.slide-show .slick-slide[aria-hidden="true"]:not(.slick-cloned) ~ .slick-cloned[aria-hidden="true"] {
  transform: scale(0.8, 0.8);
  transition: all 0.4s ease-in-out;
}
.slide-show .slick-center,
.slide-show .slick-slide[aria-hidden="true"]:not([tabindex="-1"]) + .slick-cloned[aria-hidden="true"] {
  transform: scale(1.1); 
}
.slide-show .slick-current.slick-active{
  transform: scale(1.1);
}
.slick-next, .slick-prev{
  z-index: 5;
}
.slick-next{
  right: 15px;
}
.slick-prev{
  left: 15px;
}
.slick-next:before, .slick-prev:before{
  color: #ad3030;
  font-size: 30px;
} 

More examples for slick slider

Posted in HTML, JavaScript, jQuery

You can also read...