javascript 使用 slick 从 li 元素创建轮播
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24056855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using slick to create a carousel from li elements
提问by Ecko123
I'm using slick to create a carousel from list items The structure of list is like this
我正在使用 slick 从列表项创建轮播列表的结构是这样的
<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.
我无法创建它的轮播。内容更像是一个普通列表。检查节点时,我看到相关的分类添加到 dom 中。
Link for slick :https://kenwheeler.github.io/slick/
回答by Rodriguez Lo?c
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).
实际上,Slick 默认使用 div 元素作为幻灯片,但您可以使用“幻灯片”参数更改它(幻灯片 | 元素 | 'div' | 元素查询以用作幻灯片)。
In your case you need to have (in your js) something like:
在您的情况下,您需要(在您的 js 中)具有以下内容:
$('.slicker').slick({
slide: 'li'
});
You can also change your code with 'div' like "v2solutions.com" said but this change your semantics.
您还可以使用“div”更改代码,如“v2solutions.com”所说,但这会更改您的语义。
回答by v2solutions.com
Could you please try <div> instead of <li>. slick seems to be working with <div>
only.
你能不能试试 <div> 而不是 <li>。slick 似乎<div>
只能使用。