Jquery 引导转盘一次单击即可移动单个项目

Jquery 引导转盘一次单击即可移动单个项目,jquery,css,twitter-bootstrap,Jquery,Css,Twitter Bootstrap,我有这个旋转木马 $('myCarousel')。carousel({ 间隔时间:4000 }) $('.carousel.item')。每个(函数(){ var next=$(this.next(); 如果(!next.length){ next=$(this.sibbines(':first'); } next.children(':first child').clone().appendTo($(this)); 对于(var i=0;i 由于某些原因,代码段没有显示准确的结果。请检查小提

我有这个旋转木马

$('myCarousel')。carousel({
间隔时间:4000
})
$('.carousel.item')。每个(函数(){
var next=$(this.next();
如果(!next.length){
next=$(this.sibbines(':first');
}
next.children(':first child').clone().appendTo($(this));
对于(var i=0;i
由于某些原因,代码段没有显示准确的结果。请检查小提琴

(清洁和工作版)

$('myCarousel')。carousel({
间隔:10000
})
$('.carousel.item')。每个(函数(){
var next=$(this.next();
如果(!next.length){
next=$(this.sibbines(':first');
}
next.children(':first child').clone().appendTo($(this));
if(next.next().length>0){
next.next().children(':first child').clone().appendTo($(this));
}
否则{
$(this).兄弟姐妹(':first').children(':first child').clone().appendTo($(this));
}
});
#myCarousel.carousel-inner.active.left{
左-33%;
}
#我的传送带。传送带内部。活动。右侧{
左:33%;
}
#我的传送带。传送带内部。下一个{
左:33%;
}
#我的传送带。传送带内部。上一个{
左-33%;
}
#我的转盘,转盘控制,左{
背景图像:无;
}
#我的转盘,转盘控制,对{
背景图像:无;
}
#我的传送带。传送带内部。项目{
背景:白色;
过渡:一切轻松。5s;
}

正在工作

我也遇到了同样的问题,通过在css中添加以下代码,我一次只能滑动一个项目:

#myCarousel .carousel-inner .item {
  background: white;
  /*transition: transform;*/
  transition: all 500ms ease-out; /* transition is added here */
}
试试这个: JS:

HTML:


产品传送带
您还可以通过在css中添加
过渡:所有500毫秒都会变慢;
使过渡更平滑


在这里摆弄:

你的意思是什么?你只想显示一张图像?因为如果你移动一张图像,你必须移动其余的…@Håkan实际上当前整行移动就像如果显示1,2,3,4,那么next()将首先向左移动1,2,3,4,然后出现新的2,3,4,5..右。我需要像这样移动,如果1,2,3,4显示在下一个()将从可见部分移出1,并在后面添加5。这不一样吗?你可以在@MoshFeu中看到类似你的东西也尝试使用这个…但是,在system或new fiddle中,同样的事情会发生,,,首先它移动所有4,然后一个新行包含2,3,4,5数据。可能的原因是什么?我真的不认为这是他期望的结果d、 为什么你需要滑动所有元素?他只需要移动一个。检查小提琴,它工作正常。我不知道为什么这段代码中会发生这种奇怪的事情。:/滚动时,它会对“项目”中的文本产生模糊效果。有什么办法可以避免文本变得模糊吗?我通过在文本中添加白色背景部分解决了这个问题“项目"这种方式是不透明的,所以你看不到第二行在后面滑动。有更好的主意吗?由于Bootstrap版本3.3.7,它在这里不起作用。如果你使用Bootstrap 3.0.0 CSS,那么它会很好地工作。你有没有用转换更新过它?希望看到它添加到你的答案中,使它更平滑。你可以添加``过渡`n:所有500毫秒都慢下来;`to
#myCarousel.carousel inner.item
在css中。我已经更新了我的答案。你也可以在这里查看小提琴:
$('#myCarousel').carousel({
  interval: 4000
})

$('.carousel .item').each(function(){
  var next = $(this).next();
  if (!next.length) {
    next = $(this).siblings(':first');
  }
  next.children(':first-child').clone().appendTo($(this));

  for (var i=0;i<2;i++) {
    next=next.next();
    if (!next.length) {
      next = $(this).siblings(':first');
    }

    next.children(':first-child').clone().appendTo($(this));
  }
});
.carousel-inner .active.left { left: -25%; }
.carousel-inner .next        { left:  25%; }
.carousel-inner .prev        { left: -25%; }
.carousel-control            { width:  4%; }
.carousel-control.left,.carousel-control.right {margin-left:15px;background-image:none;}

#myCarousel .carousel-inner .item {
  background: white;
  /*transition: transform;*/
  transition: all 500ms ease-out; /* transition is added here */
}
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="bootstrapCarousel.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <!-- <script type="text/javascript" src="http://twitter.github.io/bootstrap/assets/js/bootstrap-transition.js"></script>
    <script type="text/javascript" src="http://twitter.github.io/bootstrap/assets/js/bootstrap-carousel.js"></script> -->
  </head>
  <body>
  <div class="col-md-12 text-center"><h3>Product Carousel</h3></div>

<div class="col-md-6 col-md-offset-3">
<div class="carousel slide row" data-ride="carousel" data-type="multi" data-interval="3000" id="myCarousel">
  <div class="carousel-inner">
    <div class="item active">
      <div class="col-md-3 col-sm-6 col-xs-12"><a href="#"><img src="http://placehold.it/500/e499e4/fff&amp;text=1" class="img-responsive" /></a></div>
    </div>
    <div class="item">
      <div class="col-md-3 col-sm-6 col-xs-12"><a href="#"><img src="http://placehold.it/500/e477e4/fff&amp;text=2" class="img-responsive" /></a></div>
    </div>
    <div class="item">
      <div class="col-md-3 col-sm-6 col-xs-12"><a href="#"><img src="http://placehold.it/500/eeeeee&amp;text=3" class="img-responsive" /></a></div>
    </div>
    <div class="item">
      <div class="col-md-3 col-sm-6 col-xs-12"><a href="#"><img src="http://placehold.it/500/f4f4f4&amp;text=4" class="img-responsive" /></a></div>
    </div>
    <div class="item">
      <div class="col-md-3 col-sm-6 col-xs-12"><a href="#"><img src="http://placehold.it/500/f566f5/333&amp;text=5" class="img-responsive" /></a></div>
    </div>
    <div class="item">
      <div class="col-md-3 col-sm-6 col-xs-12"><a href="#"><img src="http://placehold.it/500/f477f4/fff&amp;text=6" class="img-responsive" /></a></div>
    </div>
    <div class="item">
      <div class="col-md-3 col-sm-6 col-xs-12"><a href="#"><img src="http://placehold.it/500/eeeeee&amp;text=7" class="img-responsive" /></a></div>
    </div>
    <div class="item">
      <div class="col-md-3 col-sm-6 col-xs-12"><a href="#"><img src="http://placehold.it/500/fcfcfc/333&amp;text=8" class="img-responsive" /></a></div>
    </div>
  </div>
  <a class="left carousel-control" href="#myCarousel" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i></a>
  <a class="right carousel-control" href="#myCarousel" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i></a>
</div>
</div>

<script src="https://code.jquery.com/jquery-2.0.2.min.js" type="text/javascript"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script type="text/javascript" src="bootstrapCarousel.js">
</script>
</body>
</html>