Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using slick to create a carousel from li elements

I'm using slick to create a carousel from list items The structure of list is like this

<div class="slicker">
    <li>
        <img />
    </li>
    <li>
        <img />
    </li>
    <li>
        <img />
    </li>
</div>

I'm unable to create a carousel of it . The content rather appears as a normal list. When checking the node I see the relevant classed added to the dom.

Link for slick :https://kenwheeler.github.io/slick/

like image 996
Ecko123 Avatar asked Jun 05 '14 09:06

Ecko123


People also ask

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.

How do you use slick carousel in react?

Setting up the project React Slick is the main library that provides us with the carousel component. slick-carousel provides styling for this component while react-icons will be used for importing icons. All styling for this application is located in src/index. css available in the source code.


1 Answers

Actually, Slick use div element as slide by default, but you can change it with the "slide" parameter (slide | element | 'div' | Element query to use as slide).

In your case you need to have (in your js) something like:

$('.slicker').slick({
  slide: 'li'
});

You can also change your code with 'div' like "v2solutions.com" said but this change your semantics.

like image 163
Rodriguez Loïc Avatar answered Sep 20 '22 13:09

Rodriguez Loïc