我想使用 cycle2.js slider 。我要循环的每个元素都是一个包含多个文章标签的 div 元素。
我可以用 div 替换 img 标签吗?怎么办?
<div class="cycle-slideshow"
data-cycle-fx=scrollHorz
data-cycle-timeout=0
>
<!-- prev/next links -->
<div class="cycle-prev"></div>
<div class="cycle-next"></div>
<img src="http://malsup.github.io/images/p1.jpg"> <!-- Can I convert img tags to div elements? -->
<img src="http://malsup.github.io/images/p2.jpg">
<img src="http://malsup.github.io/images/p3.jpg">
<img src="http://malsup.github.io/images/p4.jpg">
</div>
我现在正在尝试让 JS 显示其中的三篇文章,并在经过一定时间后更改显示的三篇文章。考虑到此代码的页面在奇数(损坏的)位置一次显示一篇文章。我做错了什么吗?
<div class="cycle-slifdshow" data-cycle-slider="div">
<div class="three-at-a-time">
<article> ...</article>
<article>...</article>
<article>...</article>
</div>
<div class='three-at-a-time>
...
</div>
...
</div>
最佳答案
文档说是 http://jquery.malsup.com/cycle2/faq/#non-image
I want to use slides that are not images. How do I tell Cycle2 what my slides are?
Use the data-cycle-slides attribute to provide a jQuery selector which identifies the elements within the container that are slides. For example, if your slideshow is a ul with li slides you would set the attribute like this: data-cycle-slides="li"
<ul class="cycle-slideshow" data-cycle-slides="li">
<li><img src="path/to/some/image1.jpg"></li>
<li><img src="path/to/some/image2.jpg"></li>
<li><img src="path/to/some/image3.jpg"></li>
</ul>
关于jquery - 替换 cycle2.js 中的 <img> 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30066552/