简体   繁体   English

尝试制作旋转木马滑块

[英]Trying to make a carousel slider

im trying to make a simple carousel slider with 3 slides with some content inside, now the problem is that i cant make to go to the first slide when im on the last one, so i would be thankful if anyone can give few pointers where im wrong. 即时通讯试图制作一个简单的带有3个幻灯片的旋转木马滑块,里面有一些内容,现在的问题是,当即时通讯在最后一个幻灯片上时,我无法转到第一张幻灯片,因此,如果有人能在即时通讯上提供一些指示,我将不胜感激错误。

Take a look: 看一看:

http://codepen.io/anon/pen/bNpYLB enter code here http://codepen.io/anon/pen/bNpYLB enter code here

Add a slide class to each slide. slide类添加到每张幻灯片。 Optionally, declare slider-content[x] as an id (don't forget to modify the CSS accordingly): (可选)将lider slider-content[x]声明为一个id (不要忘记相应地修改CSS):

<div class="slide" id="slider-content3">

Conduct analogical operation on the dots list: 在点列表上进行类比运算:

 <ul class="slider-dots"> <li class="dot active-dot">&bull;</li> <li class="dot">&bull;</li> <li class="dot">&bull;</li> </ul> 

And change your javascript to: 并将您的JavaScript更改为:

  if(nextSlide.length === 0) { nextSlide = $('.slide').first(); nextDot = $('.dot').first(); } 

Check on Codepen if it's the desired behaviour. 检查Codepen是否是所需的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM