This is the effect I'm trying to achieve with Bootstrap 3 carousel
这就是我试图用Bootstrap 3旋转木马实现的效果。
Instead of just showing one frame at a time, it displays N frames slide by side. Then when you slide (or when it auto slides), it shifts the group of slides like it does.
它不是一次显示一个帧,而是同时显示N个帧。当你滑动的时候(或者自动滑动的时候),它会像移动一样移动一组幻灯片。
Can this be done with bootstrap 3's carousel? I'm hoping I won't have to go hunting for yet another jQuery plugin...
这能通过引导3的旋转木马完成吗?我希望我不用再去寻找另一个jQuery插件……
13 个解决方案
#1
16
Can this be done with bootstrap 3's carousel? I'm hoping I won't have to go hunting for yet another jQuery plugin
这能通过引导3的旋转木马完成吗?我希望我不用再去寻找另一个jQuery插件
As of 2013-12-08 the answer is no. The effect you are looking for is not possible using Bootstrap 3's generic carousel plugin. However, here's a simple jQuery plugin that seems to do exactly what you want http://sorgalla.com/jcarousel/
到2013-12-08年,答案是否定的。您正在寻找的效果不可能使用Bootstrap 3的通用carousel插件。但是,这里有一个简单的jQuery插件,它似乎可以实现您想要的http://sorgalla.com/jcarousel/
#2
90
Update 2018
Bootstrap 4
引导4
The carousel has changed in 4.x, and the multi-slide animation transitions can be overridden like this...
旋转木马在4点发生了变化。多幻灯片动画转换可以这样重写……
.carousel-inner .carousel-item-right.active,
.carousel-inner .carousel-item-next {
transform: translateX(33.33%);
}
.carousel-inner .carousel-item-left.active,
.carousel-inner .carousel-item-prev {
transform: translateX(-33.33%)
}
.carousel-inner .carousel-item-right,
.carousel-inner .carousel-item-left{
transform: translateX(0);
}
Bootstrap 4 Alpha.6 Demo
Bootstrap 4.0.0 (show 4, advance 1 at a time)
Bootstrap 4.1.0 (advance all 4 at once)
Bootstrap 4 Alpha.6演示Bootstrap 4.0.0(显示4,一次前进1)Bootstrap 4.1.0(同时推进4)
Another option is a responsive carousel that only shows and advances 1 slide on smaller screens. Instead of cloning the slides like the previous example, this one adjusts the CSS and use jQuery only to move the extra slides to allow for continuous cycling (wrap around):
另一种选择是响应式旋转木马,它只在小屏幕上显示和推进1张幻灯片。不像前面的例子那样克隆幻灯片,这个例子调整了CSS,使用jQuery只移动多余的幻灯片,以允许连续循环(包装):
Don't just copy-and-paste this code. First, understand how it works.
不要只是复制粘贴这些代码。首先,了解它是如何工作的。
Bootstrap 4 Responsive (1 slide on mobile)
引导4响应(1移动幻灯片)
@media (min-width: 768px) {
/* show 3 items */
.carousel-inner .active,
.carousel-inner .active + .carousel-item,
.carousel-inner .active + .carousel-item + .carousel-item {
display: block;
}
.carousel-inner .carousel-item.active:not(.carousel-item-right):not(.carousel-item-left),
.carousel-inner .carousel-item.active:not(.carousel-item-right):not(.carousel-item-left) + .carousel-item,
.carousel-inner .carousel-item.active:not(.carousel-item-right):not(.carousel-item-left) + .carousel-item + .carousel-item {
transition: none;
}
.carousel-inner .carousel-item-next,
.carousel-inner .carousel-item-prev {
position: relative;
transform: translate3d(0, 0, 0);
}
.carousel-inner .active.carousel-item + .carousel-item + .carousel-item + .carousel-item {
position: absolute;
top: 0;
right: -33.3333%;
z-index: -1;
display: block;
visibility: visible;
}
/* left or forward direction */
.active.carousel-item-left + .carousel-item-next.carousel-item-left,
.carousel-item-next.carousel-item-left + .carousel-item,
.carousel-item-next.carousel-item-left + .carousel-item + .carousel-item,
.carousel-item-next.carousel-item-left + .carousel-item + .carousel-item + .carousel-item {
position: relative;
transform: translate3d(-100%, 0, 0);
visibility: visible;
}
/* farthest right hidden item must be abso position for animations */
.carousel-inner .carousel-item-prev.carousel-item-right {
position: absolute;
top: 0;
left: 0;
z-index: -1;
display: block;
visibility: visible;
}
/* right or prev direction */
.active.carousel-item-right + .carousel-item-prev.carousel-item-right,
.carousel-item-prev.carousel-item-right + .carousel-item,
.carousel-item-prev.carousel-item-right + .carousel-item + .carousel-item,
.carousel-item-prev.carousel-item-right + .carousel-item + .carousel-item + .carousel-item {
position: relative;
transform: translate3d(100%, 0, 0);
visibility: visible;
display: block;
visibility: visible;
}
}
Bootstrap 3
引导3
Here is a 3.x example on Bootply: http://bootply.com/89193
这是一个3。示例:http://bootply.com/89193
You need to put an entire row of images in the item active. Here is another version that doesn't stack the images at smaller screen widths: http://bootply.com/92514
您需要在项目活动中放置一整行图像。这里还有一个版本,它不会将图像叠加在更小的屏幕宽度上:http://bootply.com/92514
EDIT Alternative approach to advance one slide at a time:
编辑可选的方法,以推进一个幻灯片一次:
Use jQuery to clone the next items..
使用jQuery克隆下一个条目。
$('.carousel .item').each(function(){
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
if (next.next().length>0) {
next.next().children(':first-child').clone().appendTo($(this));
}
else {
$(this).siblings(':first').children(':first-child').clone().appendTo($(this));
}
});
And then CSS to position accordingly...
然后CSS相应地定位……
Before 3.3.1
3.3.1之前
.carousel-inner .active.left { left: -33%; }
.carousel-inner .next { left: 33%; }
After 3.3.1
3.3.1后
.carousel-inner .item.left.active {
transform: translateX(-33%);
}
.carousel-inner .item.right.active {
transform: translateX(33%);
}
.carousel-inner .item.next {
transform: translateX(33%)
}
.carousel-inner .item.prev {
transform: translateX(-33%)
}
.carousel-inner .item.right,
.carousel-inner .item.left {
transform: translateX(0);
}
This will show 3 at time, but only slide one at a time:
这将会显示3个时间,但每次只有一个幻灯片:
引导3。x演示
Please don't just copy-and-paste this code. First, understand how it works. This answer is here to help you learn.
请不要复制粘贴这些代码。首先,了解它是如何工作的。这个答案可以帮助你学习。
Doubling up this modified bootstrap 4 carousel only functions half correctly (scroll loop stops working)
how to make 2 bootstrap sliders in single page without mixing their css and jquery?
将这个修改后的bootstrap 4旋转木马加倍只有一半功能正确(滚动环停止工作)如何在一个页面中创建2个引导滑块而不混合css和jquery?
#3
19
This is a working twitter bootstrap 3.
这是一个有效的twitter引导3。
Here is the javascript:
这是javascript:
$('#myCarousel').carousel({
interval: 10000
})
$('.carousel .item').each(function(){
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
if (next.next().length>0) {
next.next().children(':first-child').clone().appendTo($(this));
}
else {
$(this).siblings(':first').children(':first-child').clone().appendTo($(this));
}
});
And the css:
css:
.carousel-inner .active.left { left: -33%; }
.carousel-inner .active.right { left: 33%; }
.carousel-inner .next { left: 33% }
.carousel-inner .prev { left: -33% }
.carousel-control.left { background-image: none; }
.carousel-control.right { background-image: none; }
.carousel-inner .item { background: white; }
You can see it in action at this Jsfiddle
你可以在Jsfiddle看到它的作用
The reason i added this answer because the other ones don't work entirely. I found 2 bugs inside them, one of them was that the left arrow generated a strange effect and the other was about the text getting bold in some situations witch can be resolved by setting the background color so the bottom item wont be visible while the transition effect.
我添加这个答案的原因是其他的并不完全有效。我在里面发现了两个bug,其中一个是左边的箭头产生了一个奇怪的效果另一个是关于文本在某些情况下变得大胆的问题女巫可以通过设置背景颜色来解决,这样底部的项目就不会出现在过渡效果的时候。
#4
17
All the above solutions are hacky and buggy. Don't even try. Use other libs. The best I have found - http://sachinchoolur.github.io/lightslider Works great with bootstrap, does not add junk html, highly-configurable, responsive, mobile-friendly etc...
以上所有的解决方案都很陈腐。甚至不尝试。使用其他填词。我找到的最好的东西——http://sachinchoolur.github。io/lightslider与bootstrap配合非常好,不添加垃圾html、高度可配置、响应迅速、移动友好等……
$('.multi-item-carousel').lightSlider({
item: 4,
pager: false,
autoWidth: false,
slideMargin: 0
});
#5
4
This is what worked for me. Very simple jQuery and CSS to make responsive carousel works independently of carousels on the same page. Highly customizable but basically a div with white-space nowrap containing a bunch of inline-block elements and put the last one at the beginning to move back or the first one to the end to move forward. Thank you insertAfter
!
这对我起了作用。非常简单的jQuery和CSS使响应性的旋转木马独立于同一页面上的旋转木马。高度可定制,但基本上是一个div,它有一个空白的nowrap,它包含了一组行-块元素,并将最后一个元素放在前面移动,或者将第一个元素放在后面移动。谢谢你insertAfter !
$('.carosel-control-right').click(function() {
$(this).blur();
$(this).parent().find('.carosel-item').first().insertAfter($(this).parent().find('.carosel-item').last());
});
$('.carosel-control-left').click(function() {
$(this).blur();
$(this).parent().find('.carosel-item').last().insertBefore($(this).parent().find('.carosel-item').first());
});
@media (max-width: 300px) {
.carosel-item {
width: 100%;
}
}
@media (min-width: 300px) {
.carosel-item {
width: 50%;
}
}
@media (min-width: 500px) {
.carosel-item {
width: 33.333%;
}
}
@media (min-width: 768px) {
.carosel-item {
width: 25%;
}
}
.carosel {
position: relative;
background-color: #000;
}
.carosel-inner {
white-space: nowrap;
overflow: hidden;
font-size: 0;
}
.carosel-item {
display: inline-block;
}
.carosel-control {
position: absolute;
top: 50%;
padding: 15px;
box-shadow: 0 0 10px 0px rgba(0, 0, 0, 0.5);
transform: translateY(-50%);
border-radius: 50%;
color: rgba(0, 0, 0, 0.5);
font-size: 30px;
display: inline-block;
}
.carosel-control-left {
left: 15px;
}
.carosel-control-right {
right: 15px;
}
.carosel-control:active,
.carosel-control:hover {
text-decoration: none;
color: rgba(0, 0, 0, 0.8);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="carosel" id="carosel1">
<a class="carosel-control carosel-control-left glyphicon glyphicon-chevron-left" href="#"></a>
<div class="carosel-inner">
<img class="carosel-item" src="http://placehold.it/500/bbbbbb/fff&text=1" />
<img class="carosel-item" src="http://placehold.it/500/CCCCCC&text=2" />
<img class="carosel-item" src="http://placehold.it/500/eeeeee&text=3" />
<img class="carosel-item" src="http://placehold.it/500/f4f4f4&text=4" />
<img class="carosel-item" src="http://placehold.it/500/fcfcfc/333&text=5" />
<img class="carosel-item" src="http://placehold.it/500/f477f4/fff&text=6" />
</div>
<a class="carosel-control carosel-control-right glyphicon glyphicon-chevron-right" href="#"></a>
</div>
<div class="carosel" id="carosel2">
<a class="carosel-control carosel-control-left glyphicon glyphicon-chevron-left" href="#"></a>
<div class="carosel-inner">
<img class="carosel-item" src="http://placehold.it/500/bbbbbb/fff&text=1" />
<img class="carosel-item" src="http://placehold.it/500/CCCCCC&text=2" />
<img class="carosel-item" src="http://placehold.it/500/eeeeee&text=3" />
<img class="carosel-item" src="http://placehold.it/500/f4f4f4&text=4" />
<img class="carosel-item" src="http://placehold.it/500/fcfcfc/333&text=5" />
<img class="carosel-item" src="http://placehold.it/500/f477f4/fff&text=6" />
</div>
<a class="carosel-control carosel-control-right glyphicon glyphicon-chevron-right" href="#"></a>
</div>
#6
3
The most popular answer is right but I think the code is uselessly complicated. With the same css, this jquery code is easier to understand I believe:
最流行的答案是对的,但我认为代码是无用的复杂。使用同样的css,我相信这个jquery代码更容易理解:
$('#myCarousel').carousel({
interval: 10000
})
$('.carousel .item').each(function() {
var item = $(this);
item.siblings().each(function(index) {
if (index < 4) {
$(this).children(':first-child').clone().appendTo(item);
}
});
});
#7
2
try this.....it work in mine.... code:
试试这个.....它在我的....代码:
<div class="container">
<br>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<div class="span4" style="padding-left: 18px;">
<img src="http://placehold.it/290x180" class="img-thumbnail">
<img src="http://placehold.it/290x180" class="img-thumbnail">
<img src="http://placehold.it/290x180" class="img-thumbnail">
</div>
</div>
<div class="item">
<div class="span4" style="padding-left: 18px;">
<img src="http://placehold.it/290x180" class="img-thumbnail">
<img src="http://placehold.it/290x180" class="img-thumbnail">
<img src="http://placehold.it/290x180" class="img-thumbnail">
</div>
</div>
</div>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
#8
2
$('#carousel-example-generic').on('slid.bs.carousel', function () {
$(".item.active:nth-child(" + ($(".carousel-inner .item").length -1) + ") + .item").insertBefore($(".item:first-child"));
$(".item.active:last-child").insertBefore($(".item:first-child"));
});
.item.active,
.item.active + .item,
.item.active + .item + .item {
width: 33.3%;
display: block;
float:left;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel" style="max-width:800px;">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img data-src="holder.js/300x200?text=1">
</div>
<div class="item">
<img data-src="holder.js/300x200?text=2">
</div>
<div class="item">
<img data-src="holder.js/300x200?text=3">
</div>
<div class="item">
<img data-src="holder.js/300x200?text=4">
</div>
<div class="item">
<img data-src="holder.js/300x200?text=5">
</div>
<div class="item">
<img data-src="holder.js/300x200?text=6">
</div>
<div class="item">
<img data-src="holder.js/300x200?text=7">
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/holder/2.9.1/holder.min.js"></script>
#9
0
I had the same problem and the solutions described here worked well. But I wanted to support window size (and layout) changes. The result is a small library that solves all the calculation. Check it out here: https://github.com/SocialbitGmbH/BootstrapCarouselPageMerger
我也遇到了同样的问题,这里描述的解决方案运行得很好。但是我想支持窗口大小(和布局)的改变。结果是一个小的库解决了所有的计算。点击这里查看:https://github.com/socialbitgmbh/bootstrapcarouselpager
To make the script work, you have to add a new <div>
wrapper with the class .item-content
directly into your .item
<div>
. Example:
要使脚本正常工作,您必须在.item
<div class="carousel slide multiple" id="very-cool-carousel" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="item active">
<div class="item-content">
First page
</div>
</div>
<div class="item active">
<div class="item-content">
Second page
</div>
</div>
</div>
</div>
Usage of this library:
使用这个库:
socialbitBootstrapCarouselPageMerger.run('div.carousel');
To change the settings:
更改设置:
socialbitBootstrapCarouselPageMerger.settings.spaceCalculationFactor = 0.82;
Example:
例子:
As you can see, the carousel gets updated to show more controls when you resize the window. Check out the watchWindowSizeTimeout
setting to control the timeout for reacting to window size changes.
正如您所看到的,当您调整窗口大小时,旋转木马将被更新以显示更多的控件。检查watchWindowSizeTimeout设置,以控制响应窗口大小更改的超时。
#10
0
<!--css code-->
.carousel-showsixmoveone .carousel-control {
width: 4%;
background-image: none;
}
.carousel-showsixmoveone .carousel-control.left {
margin-left: 15px;
}
.carousel-showsixmoveone .carousel-control.right {
margin-right: 15px;
}
.carousel-showsixmoveone .cloneditem-1,
.carousel-showsixmoveone .cloneditem-2,
.carousel-showsixmoveone .cloneditem-3,
.carousel-showsixmoveone .cloneditem-4,
.carousel-showsixmoveone .cloneditem-5 {
display: none;
}
@media all and (min-width: 768px) {
.carousel-showsixmoveone .carousel-inner > .active.left,
.carousel-showsixmoveone .carousel-inner > .prev {
left: -33.333%;
}
.carousel-showsixmoveone .carousel-inner > .active.right,
.carousel-showsixmoveone .carousel-inner > .next {
left: 33.333%;
}
.carousel-showsixmoveone .carousel-inner > .left,
.carousel-showsixmoveone .carousel-inner > .prev.right,
.carousel-showsixmoveone .carousel-inner > .active {
left: 0;
}
.carousel-showsixmoveone .carousel-inner .cloneditem-1,
.carousel-showsixmoveone .carousel-inner .cloneditem-2 {
display: block;
}
}
@media all and (min-width: 768px) and (transform-3d),
all and (min-width: 768px) and (-webkit-transform-3d) {
.carousel-showsixmoveone .carousel-inner > .item.active.right,
.carousel-showsixmoveone .carousel-inner > .item.next {
-webkit-transform: translate3d(33.333%, 0, 0);
transform: translate3d(33.333%, 0, 0);
left: 0;
}
.carousel-showsixmoveone .carousel-inner > .item.active.left,
.carousel-showsixmoveone .carousel-inner > .item.prev {
-webkit-transform: translate3d(-33.333%, 0, 0);
transform: translate3d(-33.333%, 0, 0);
left: 0;
}
.carousel-showsixmoveone .carousel-inner > .item.left,
.carousel-showsixmoveone .carousel-inner > .item.prev.right,
.carousel-showsixmoveone .carousel-inner > .item.active {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
left: 0;
}
}
@media all and (min-width: 992px) {
.carousel-showsixmoveone .carousel-inner > .active.left,
.carousel-showsixmoveone .carousel-inner > .prev {
left: -16.666%;
}
.carousel-showsixmoveone .carousel-inner > .active.right,
.carousel-showsixmoveone .carousel-inner > .next {
left: 16.666%;
}
.carousel-showsixmoveone .carousel-inner > .left,
.carousel-showsixmoveone .carousel-inner > .prev.right,
.carousel-showsixmoveone .carousel-inner > .active {
left: 0;
}
.carousel-showsixmoveone .carousel-inner .cloneditem-3,
.carousel-showsixmoveone .carousel-inner .cloneditem-4,
.carousel-showsixmoveone .carousel-inner .cloneditem-5 {
display: block;
}
}
@media all and (min-width: 992px) and (transform-3d),
all and (min-width: 992px) and (-webkit-transform-3d) {
.carousel-showsixmoveone .carousel-inner > .item.active.right,
.carousel-showsixmoveone .carousel-inner > .item.next {
-webkit-transform: translate3d(16.666%, 0, 0);
transform: translate3d(16.666%, 0, 0);
left: 0;
}
.carousel-showsixmoveone .carousel-inner > .item.active.left,
.carousel-showsixmoveone .carousel-inner > .item.prev {
-webkit-transform: translate3d(-16.666%, 0, 0);
transform: translate3d(-16.666%, 0, 0);
left: 0;
}
.carousel-showsixmoveone .carousel-inner > .item.left,
.carousel-showsixmoveone .carousel-inner > .item.prev.right,
.carousel-showsixmoveone .carousel-inner > .item.active {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
left: 0;
}
}
<!-- begin snippet: js hide: false console: true -->
<!--html-->
<div class="row ">
<div class="col-md-12">
<div class="carousel carousel-showsixmoveone slide" id="chocolatelist" data-interval="30000">
<div class="carousel-inner">
<div class="item active">
<div class="col-xs-12 col-sm-4 col-md-2">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=1" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-1">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=2" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-2">
<a href="#">
<img src="http://placehold.it/500/d6d6d6/333&text=3" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-3">
<a href="#">
<img src="http://placehold.it/500/002040/eeeeee&text=4" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-4">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=5" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-5">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=6" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-4 col-md-2">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=2" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-1">
<a href="#">
<img src="http://placehold.it/500/d6d6d6/333&text=3" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-2">
<a href="#">
<img src="http://placehold.it/500/002040/eeeeee&text=4" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-3">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=5" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-4">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=6" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-5">
<a href="#">
<img src="http://placehold.it/500/eeeeee&text=7" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-4 col-md-2">
<a href="#">
<img src="http://placehold.it/500/d6d6d6/333&text=3" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-1">
<a href="#">
<img src="http://placehold.it/500/002040/eeeeee&text=4" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-2">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=5" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-3">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=6" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-4">
<a href="#">
<img src="http://placehold.it/500/eeeeee&text=7" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-5">
<a href="#">
<img src="http://placehold.it/500/40a1ff/002040&text=8" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-4 col-md-2">
<a href="#">
<img src="http://placehold.it/500/002040/eeeeee&text=4" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-1">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=5" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-2">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=6" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-3">
<a href="#">
<img src="http://placehold.it/500/eeeeee&text=7" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-4">
<a href="#">
<img src="http://placehold.it/500/40a1ff/002040&text=8" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-5">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=1" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-4 col-md-2">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=5" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-1">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=6" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-2">
<a href="#">
<img src="http://placehold.it/500/eeeeee&text=7" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-3">
<a href="#">
<img src="http://placehold.it/500/40a1ff/002040&text=8" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-4">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=1" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-5">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=2" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-4 col-md-2">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=6" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-1">
<a href="#">
<img src="http://placehold.it/500/eeeeee&text=7" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-2">
<a href="#">
<img src="http://placehold.it/500/40a1ff/002040&text=8" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-3">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=1" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-4">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=2" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-5">
<a href="#">
<img src="http://placehold.it/500/d6d6d6/333&text=3" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-4 col-md-2">
<a href="#">
<img src="http://placehold.it/500/eeeeee&text=7" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-1">
<a href="#">
<img src="http://placehold.it/500/40a1ff/002040&text=8" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-2">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=1" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-3">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=2" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-4">
<a href="#">
<img src="http://placehold.it/500/d6d6d6/333&text=3" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-5">
<a href="#">
<img src="http://placehold.it/500/002040/eeeeee&text=4" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-4 col-md-2">
<a href="#">
<img src="http://placehold.it/500/40a1ff/002040&text=8" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-1">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=1" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-2">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=2" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-3">
<a href="#">
<img src="http://placehold.it/500/d6d6d6/333&text=3" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-4">
<a href="#">
<img src="http://placehold.it/500/002040/eeeeee&text=4" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-5">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=5" class="img-responsive">
</a>
</div>
</div>
</div>
<a class="left carousel-control" href="#chocolatelist" data-slide="prev"><i class="glyphicon glyphicon-chevron-left "></i></a>
<a class="right carousel-control" href="#chocolatelist" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i></a>
</div>
</div>
</div>
paste this code you will get some clue.image link of carousel slide
粘贴这段代码你会得到一些线索。旋转木马幻灯片的图像链接
#11
0
Try this code
<div id="recommended-item-carousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="item active">
<div class="col-sm-3">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<img src="img/home/recommend1.jpg" alt="" />
<h2>$56</h2>
<p>
Easy Polo Black Edition
</p>
<a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
</div>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<img src="img/home/recommend2.jpg" alt="" />
<h2>$56</h2>
<p>
Easy Polo Black Edition
</p>
<a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
</div>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<img src="img/home/recommend3.jpg" alt="" />
<h2>$56</h2>
<p>
Easy Polo Black Edition
</p>
<a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<div class="col-sm-3">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<img src="img/home/recommend1.jpg" alt="" />
<h2>$56</h2>
<p>
Easy Polo Black Edition
</p>
<a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
</div>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<img src="img/home/recommend2.jpg" alt="" />
<h2>$56</h2>
<p>
Easy Polo Black Edition
</p>
<a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
</div>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<img src="img/home/recommend3.jpg" alt="" />
<h2>$56</h2>
<p>
Easy Polo Black Edition
</p>
<a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
</div>
</div>
</div>
</div>
</div>
</div>
<a class="left recommended-item-control" href="#recommended-item-carousel" data-slide="prev"> <i class="fa fa-angle-left"></i> </a>
<a class="right recommended-item-control" href="#recommended-item-carousel" data-slide="next"> <i class="fa fa-angle-right"></i> </a>
</div>
#12
0
I've seen your question and answers, and made a new responsive and flexible multi items carousel Gist. you can see it here:
我看到了你的问题和答案,并作出了一个新的响应和灵活的多项目旋转的要点。你可以在这里看到:
https://gist.github.com/IVIR3zaM/d143a361e61459146ae7c68ce86b066e
https://gist.github.com/IVIR3zaM/d143a361e61459146ae7c68ce86b066e
#13
-1
You can add multiple li in ol tag that has attribute as class with value "carousel-indicators" and with data-slide-to has sequential values like 0 to 6 or 0 to 9.
您可以在ol标记中添加多个li,这些li具有属性为class,具有值“carousell -indicators”和数据条,具有从0到6或从0到9的顺序值。
than you just need to copy and paste the div which has attribute as class with value "item".
您只需要复制和粘贴具有值“项”属性的div。
This works for me.
这适合我。
<div data-ride="carousel" class="carousel slide" id="myCarousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li class="" data-slide-to="0" data-target="#myCarousel"></li>
<li data-slide-to="1" data-target="#myCarousel" class=""></li>
<li data-slide-to="2" data-target="#myCarousel" class="active"></li>
<li data-slide-to="3" data-target="#myCarousel" class=""></li>
<li data-slide-to="4" data-target="#myCarousel" class=""></li>
<li data-slide-to="5" data-target="#myCarousel" class=""></li>
<li data-slide-to="6" data-target="#myCarousel" class=""></li>
</ol>
<div role="listbox" class="carousel-inner">
<div class="item active">
<img alt="First slide" src="images/carousel/11.jpg"
class="first-slide">
</div>
<div class="item">
<img alt="Second slide" src="images/carousel/22.jpg"
class="second-slide">
</div>
<div class="item">
<img alt="Third slide" src="images/carousel/33.jpg"
class="third-slide">
</div>
<div class="item">
<img alt="Third slide" src="images/carousel/44.jpeg"
class="fourth-slide">
</div>
<div class="item">
<img alt="Third slide" src="images/carousel/55.jpg"
class="third-slide">
</div>
<div class="item">
<img alt="Third slide" src="images/carousel/66.jpg"
class="third-slide">
</div>
<div class="item">
<img alt="Third slide" src="images/carousel/77.jpg"
class="third-slide">
</div>
</div>
<a data-slide="prev" role="button" href="#myCarousel"
class="left carousel-control"> <span aria-hidden="true"
class="glyphicon glyphicon-chevron-left"></span> <span
class="sr-only">Previous</span>
</a> <a data-slide="next" role="button" href="#myCarousel"
class="right carousel-control"> <span aria-hidden="true"
class="glyphicon glyphicon-chevron-right"></span> <span
class="sr-only">Next</span>
</a>
</div>
#1
16
Can this be done with bootstrap 3's carousel? I'm hoping I won't have to go hunting for yet another jQuery plugin
这能通过引导3的旋转木马完成吗?我希望我不用再去寻找另一个jQuery插件
As of 2013-12-08 the answer is no. The effect you are looking for is not possible using Bootstrap 3's generic carousel plugin. However, here's a simple jQuery plugin that seems to do exactly what you want http://sorgalla.com/jcarousel/
到2013-12-08年,答案是否定的。您正在寻找的效果不可能使用Bootstrap 3的通用carousel插件。但是,这里有一个简单的jQuery插件,它似乎可以实现您想要的http://sorgalla.com/jcarousel/
#2
90
Update 2018
Bootstrap 4
引导4
The carousel has changed in 4.x, and the multi-slide animation transitions can be overridden like this...
旋转木马在4点发生了变化。多幻灯片动画转换可以这样重写……
.carousel-inner .carousel-item-right.active,
.carousel-inner .carousel-item-next {
transform: translateX(33.33%);
}
.carousel-inner .carousel-item-left.active,
.carousel-inner .carousel-item-prev {
transform: translateX(-33.33%)
}
.carousel-inner .carousel-item-right,
.carousel-inner .carousel-item-left{
transform: translateX(0);
}
Bootstrap 4 Alpha.6 Demo
Bootstrap 4.0.0 (show 4, advance 1 at a time)
Bootstrap 4.1.0 (advance all 4 at once)
Bootstrap 4 Alpha.6演示Bootstrap 4.0.0(显示4,一次前进1)Bootstrap 4.1.0(同时推进4)
Another option is a responsive carousel that only shows and advances 1 slide on smaller screens. Instead of cloning the slides like the previous example, this one adjusts the CSS and use jQuery only to move the extra slides to allow for continuous cycling (wrap around):
另一种选择是响应式旋转木马,它只在小屏幕上显示和推进1张幻灯片。不像前面的例子那样克隆幻灯片,这个例子调整了CSS,使用jQuery只移动多余的幻灯片,以允许连续循环(包装):
Don't just copy-and-paste this code. First, understand how it works.
不要只是复制粘贴这些代码。首先,了解它是如何工作的。
Bootstrap 4 Responsive (1 slide on mobile)
引导4响应(1移动幻灯片)
@media (min-width: 768px) {
/* show 3 items */
.carousel-inner .active,
.carousel-inner .active + .carousel-item,
.carousel-inner .active + .carousel-item + .carousel-item {
display: block;
}
.carousel-inner .carousel-item.active:not(.carousel-item-right):not(.carousel-item-left),
.carousel-inner .carousel-item.active:not(.carousel-item-right):not(.carousel-item-left) + .carousel-item,
.carousel-inner .carousel-item.active:not(.carousel-item-right):not(.carousel-item-left) + .carousel-item + .carousel-item {
transition: none;
}
.carousel-inner .carousel-item-next,
.carousel-inner .carousel-item-prev {
position: relative;
transform: translate3d(0, 0, 0);
}
.carousel-inner .active.carousel-item + .carousel-item + .carousel-item + .carousel-item {
position: absolute;
top: 0;
right: -33.3333%;
z-index: -1;
display: block;
visibility: visible;
}
/* left or forward direction */
.active.carousel-item-left + .carousel-item-next.carousel-item-left,
.carousel-item-next.carousel-item-left + .carousel-item,
.carousel-item-next.carousel-item-left + .carousel-item + .carousel-item,
.carousel-item-next.carousel-item-left + .carousel-item + .carousel-item + .carousel-item {
position: relative;
transform: translate3d(-100%, 0, 0);
visibility: visible;
}
/* farthest right hidden item must be abso position for animations */
.carousel-inner .carousel-item-prev.carousel-item-right {
position: absolute;
top: 0;
left: 0;
z-index: -1;
display: block;
visibility: visible;
}
/* right or prev direction */
.active.carousel-item-right + .carousel-item-prev.carousel-item-right,
.carousel-item-prev.carousel-item-right + .carousel-item,
.carousel-item-prev.carousel-item-right + .carousel-item + .carousel-item,
.carousel-item-prev.carousel-item-right + .carousel-item + .carousel-item + .carousel-item {
position: relative;
transform: translate3d(100%, 0, 0);
visibility: visible;
display: block;
visibility: visible;
}
}
Bootstrap 3
引导3
Here is a 3.x example on Bootply: http://bootply.com/89193
这是一个3。示例:http://bootply.com/89193
You need to put an entire row of images in the item active. Here is another version that doesn't stack the images at smaller screen widths: http://bootply.com/92514
您需要在项目活动中放置一整行图像。这里还有一个版本,它不会将图像叠加在更小的屏幕宽度上:http://bootply.com/92514
EDIT Alternative approach to advance one slide at a time:
编辑可选的方法,以推进一个幻灯片一次:
Use jQuery to clone the next items..
使用jQuery克隆下一个条目。
$('.carousel .item').each(function(){
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
if (next.next().length>0) {
next.next().children(':first-child').clone().appendTo($(this));
}
else {
$(this).siblings(':first').children(':first-child').clone().appendTo($(this));
}
});
And then CSS to position accordingly...
然后CSS相应地定位……
Before 3.3.1
3.3.1之前
.carousel-inner .active.left { left: -33%; }
.carousel-inner .next { left: 33%; }
After 3.3.1
3.3.1后
.carousel-inner .item.left.active {
transform: translateX(-33%);
}
.carousel-inner .item.right.active {
transform: translateX(33%);
}
.carousel-inner .item.next {
transform: translateX(33%)
}
.carousel-inner .item.prev {
transform: translateX(-33%)
}
.carousel-inner .item.right,
.carousel-inner .item.left {
transform: translateX(0);
}
This will show 3 at time, but only slide one at a time:
这将会显示3个时间,但每次只有一个幻灯片:
引导3。x演示
Please don't just copy-and-paste this code. First, understand how it works. This answer is here to help you learn.
请不要复制粘贴这些代码。首先,了解它是如何工作的。这个答案可以帮助你学习。
Doubling up this modified bootstrap 4 carousel only functions half correctly (scroll loop stops working)
how to make 2 bootstrap sliders in single page without mixing their css and jquery?
将这个修改后的bootstrap 4旋转木马加倍只有一半功能正确(滚动环停止工作)如何在一个页面中创建2个引导滑块而不混合css和jquery?
#3
19
This is a working twitter bootstrap 3.
这是一个有效的twitter引导3。
Here is the javascript:
这是javascript:
$('#myCarousel').carousel({
interval: 10000
})
$('.carousel .item').each(function(){
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
if (next.next().length>0) {
next.next().children(':first-child').clone().appendTo($(this));
}
else {
$(this).siblings(':first').children(':first-child').clone().appendTo($(this));
}
});
And the css:
css:
.carousel-inner .active.left { left: -33%; }
.carousel-inner .active.right { left: 33%; }
.carousel-inner .next { left: 33% }
.carousel-inner .prev { left: -33% }
.carousel-control.left { background-image: none; }
.carousel-control.right { background-image: none; }
.carousel-inner .item { background: white; }
You can see it in action at this Jsfiddle
你可以在Jsfiddle看到它的作用
The reason i added this answer because the other ones don't work entirely. I found 2 bugs inside them, one of them was that the left arrow generated a strange effect and the other was about the text getting bold in some situations witch can be resolved by setting the background color so the bottom item wont be visible while the transition effect.
我添加这个答案的原因是其他的并不完全有效。我在里面发现了两个bug,其中一个是左边的箭头产生了一个奇怪的效果另一个是关于文本在某些情况下变得大胆的问题女巫可以通过设置背景颜色来解决,这样底部的项目就不会出现在过渡效果的时候。
#4
17
All the above solutions are hacky and buggy. Don't even try. Use other libs. The best I have found - http://sachinchoolur.github.io/lightslider Works great with bootstrap, does not add junk html, highly-configurable, responsive, mobile-friendly etc...
以上所有的解决方案都很陈腐。甚至不尝试。使用其他填词。我找到的最好的东西——http://sachinchoolur.github。io/lightslider与bootstrap配合非常好,不添加垃圾html、高度可配置、响应迅速、移动友好等……
$('.multi-item-carousel').lightSlider({
item: 4,
pager: false,
autoWidth: false,
slideMargin: 0
});
#5
4
This is what worked for me. Very simple jQuery and CSS to make responsive carousel works independently of carousels on the same page. Highly customizable but basically a div with white-space nowrap containing a bunch of inline-block elements and put the last one at the beginning to move back or the first one to the end to move forward. Thank you insertAfter
!
这对我起了作用。非常简单的jQuery和CSS使响应性的旋转木马独立于同一页面上的旋转木马。高度可定制,但基本上是一个div,它有一个空白的nowrap,它包含了一组行-块元素,并将最后一个元素放在前面移动,或者将第一个元素放在后面移动。谢谢你insertAfter !
$('.carosel-control-right').click(function() {
$(this).blur();
$(this).parent().find('.carosel-item').first().insertAfter($(this).parent().find('.carosel-item').last());
});
$('.carosel-control-left').click(function() {
$(this).blur();
$(this).parent().find('.carosel-item').last().insertBefore($(this).parent().find('.carosel-item').first());
});
@media (max-width: 300px) {
.carosel-item {
width: 100%;
}
}
@media (min-width: 300px) {
.carosel-item {
width: 50%;
}
}
@media (min-width: 500px) {
.carosel-item {
width: 33.333%;
}
}
@media (min-width: 768px) {
.carosel-item {
width: 25%;
}
}
.carosel {
position: relative;
background-color: #000;
}
.carosel-inner {
white-space: nowrap;
overflow: hidden;
font-size: 0;
}
.carosel-item {
display: inline-block;
}
.carosel-control {
position: absolute;
top: 50%;
padding: 15px;
box-shadow: 0 0 10px 0px rgba(0, 0, 0, 0.5);
transform: translateY(-50%);
border-radius: 50%;
color: rgba(0, 0, 0, 0.5);
font-size: 30px;
display: inline-block;
}
.carosel-control-left {
left: 15px;
}
.carosel-control-right {
right: 15px;
}
.carosel-control:active,
.carosel-control:hover {
text-decoration: none;
color: rgba(0, 0, 0, 0.8);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="carosel" id="carosel1">
<a class="carosel-control carosel-control-left glyphicon glyphicon-chevron-left" href="#"></a>
<div class="carosel-inner">
<img class="carosel-item" src="http://placehold.it/500/bbbbbb/fff&text=1" />
<img class="carosel-item" src="http://placehold.it/500/CCCCCC&text=2" />
<img class="carosel-item" src="http://placehold.it/500/eeeeee&text=3" />
<img class="carosel-item" src="http://placehold.it/500/f4f4f4&text=4" />
<img class="carosel-item" src="http://placehold.it/500/fcfcfc/333&text=5" />
<img class="carosel-item" src="http://placehold.it/500/f477f4/fff&text=6" />
</div>
<a class="carosel-control carosel-control-right glyphicon glyphicon-chevron-right" href="#"></a>
</div>
<div class="carosel" id="carosel2">
<a class="carosel-control carosel-control-left glyphicon glyphicon-chevron-left" href="#"></a>
<div class="carosel-inner">
<img class="carosel-item" src="http://placehold.it/500/bbbbbb/fff&text=1" />
<img class="carosel-item" src="http://placehold.it/500/CCCCCC&text=2" />
<img class="carosel-item" src="http://placehold.it/500/eeeeee&text=3" />
<img class="carosel-item" src="http://placehold.it/500/f4f4f4&text=4" />
<img class="carosel-item" src="http://placehold.it/500/fcfcfc/333&text=5" />
<img class="carosel-item" src="http://placehold.it/500/f477f4/fff&text=6" />
</div>
<a class="carosel-control carosel-control-right glyphicon glyphicon-chevron-right" href="#"></a>
</div>
#6
3
The most popular answer is right but I think the code is uselessly complicated. With the same css, this jquery code is easier to understand I believe:
最流行的答案是对的,但我认为代码是无用的复杂。使用同样的css,我相信这个jquery代码更容易理解:
$('#myCarousel').carousel({
interval: 10000
})
$('.carousel .item').each(function() {
var item = $(this);
item.siblings().each(function(index) {
if (index < 4) {
$(this).children(':first-child').clone().appendTo(item);
}
});
});
#7
2
try this.....it work in mine.... code:
试试这个.....它在我的....代码:
<div class="container">
<br>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<div class="span4" style="padding-left: 18px;">
<img src="http://placehold.it/290x180" class="img-thumbnail">
<img src="http://placehold.it/290x180" class="img-thumbnail">
<img src="http://placehold.it/290x180" class="img-thumbnail">
</div>
</div>
<div class="item">
<div class="span4" style="padding-left: 18px;">
<img src="http://placehold.it/290x180" class="img-thumbnail">
<img src="http://placehold.it/290x180" class="img-thumbnail">
<img src="http://placehold.it/290x180" class="img-thumbnail">
</div>
</div>
</div>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
#8
2
$('#carousel-example-generic').on('slid.bs.carousel', function () {
$(".item.active:nth-child(" + ($(".carousel-inner .item").length -1) + ") + .item").insertBefore($(".item:first-child"));
$(".item.active:last-child").insertBefore($(".item:first-child"));
});
.item.active,
.item.active + .item,
.item.active + .item + .item {
width: 33.3%;
display: block;
float:left;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel" style="max-width:800px;">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img data-src="holder.js/300x200?text=1">
</div>
<div class="item">
<img data-src="holder.js/300x200?text=2">
</div>
<div class="item">
<img data-src="holder.js/300x200?text=3">
</div>
<div class="item">
<img data-src="holder.js/300x200?text=4">
</div>
<div class="item">
<img data-src="holder.js/300x200?text=5">
</div>
<div class="item">
<img data-src="holder.js/300x200?text=6">
</div>
<div class="item">
<img data-src="holder.js/300x200?text=7">
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/holder/2.9.1/holder.min.js"></script>
#9
0
I had the same problem and the solutions described here worked well. But I wanted to support window size (and layout) changes. The result is a small library that solves all the calculation. Check it out here: https://github.com/SocialbitGmbH/BootstrapCarouselPageMerger
我也遇到了同样的问题,这里描述的解决方案运行得很好。但是我想支持窗口大小(和布局)的改变。结果是一个小的库解决了所有的计算。点击这里查看:https://github.com/socialbitgmbh/bootstrapcarouselpager
To make the script work, you have to add a new <div>
wrapper with the class .item-content
directly into your .item
<div>
. Example:
要使脚本正常工作,您必须在.item
<div class="carousel slide multiple" id="very-cool-carousel" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="item active">
<div class="item-content">
First page
</div>
</div>
<div class="item active">
<div class="item-content">
Second page
</div>
</div>
</div>
</div>
Usage of this library:
使用这个库:
socialbitBootstrapCarouselPageMerger.run('div.carousel');
To change the settings:
更改设置:
socialbitBootstrapCarouselPageMerger.settings.spaceCalculationFactor = 0.82;
Example:
例子:
As you can see, the carousel gets updated to show more controls when you resize the window. Check out the watchWindowSizeTimeout
setting to control the timeout for reacting to window size changes.
正如您所看到的,当您调整窗口大小时,旋转木马将被更新以显示更多的控件。检查watchWindowSizeTimeout设置,以控制响应窗口大小更改的超时。
#10
0
<!--css code-->
.carousel-showsixmoveone .carousel-control {
width: 4%;
background-image: none;
}
.carousel-showsixmoveone .carousel-control.left {
margin-left: 15px;
}
.carousel-showsixmoveone .carousel-control.right {
margin-right: 15px;
}
.carousel-showsixmoveone .cloneditem-1,
.carousel-showsixmoveone .cloneditem-2,
.carousel-showsixmoveone .cloneditem-3,
.carousel-showsixmoveone .cloneditem-4,
.carousel-showsixmoveone .cloneditem-5 {
display: none;
}
@media all and (min-width: 768px) {
.carousel-showsixmoveone .carousel-inner > .active.left,
.carousel-showsixmoveone .carousel-inner > .prev {
left: -33.333%;
}
.carousel-showsixmoveone .carousel-inner > .active.right,
.carousel-showsixmoveone .carousel-inner > .next {
left: 33.333%;
}
.carousel-showsixmoveone .carousel-inner > .left,
.carousel-showsixmoveone .carousel-inner > .prev.right,
.carousel-showsixmoveone .carousel-inner > .active {
left: 0;
}
.carousel-showsixmoveone .carousel-inner .cloneditem-1,
.carousel-showsixmoveone .carousel-inner .cloneditem-2 {
display: block;
}
}
@media all and (min-width: 768px) and (transform-3d),
all and (min-width: 768px) and (-webkit-transform-3d) {
.carousel-showsixmoveone .carousel-inner > .item.active.right,
.carousel-showsixmoveone .carousel-inner > .item.next {
-webkit-transform: translate3d(33.333%, 0, 0);
transform: translate3d(33.333%, 0, 0);
left: 0;
}
.carousel-showsixmoveone .carousel-inner > .item.active.left,
.carousel-showsixmoveone .carousel-inner > .item.prev {
-webkit-transform: translate3d(-33.333%, 0, 0);
transform: translate3d(-33.333%, 0, 0);
left: 0;
}
.carousel-showsixmoveone .carousel-inner > .item.left,
.carousel-showsixmoveone .carousel-inner > .item.prev.right,
.carousel-showsixmoveone .carousel-inner > .item.active {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
left: 0;
}
}
@media all and (min-width: 992px) {
.carousel-showsixmoveone .carousel-inner > .active.left,
.carousel-showsixmoveone .carousel-inner > .prev {
left: -16.666%;
}
.carousel-showsixmoveone .carousel-inner > .active.right,
.carousel-showsixmoveone .carousel-inner > .next {
left: 16.666%;
}
.carousel-showsixmoveone .carousel-inner > .left,
.carousel-showsixmoveone .carousel-inner > .prev.right,
.carousel-showsixmoveone .carousel-inner > .active {
left: 0;
}
.carousel-showsixmoveone .carousel-inner .cloneditem-3,
.carousel-showsixmoveone .carousel-inner .cloneditem-4,
.carousel-showsixmoveone .carousel-inner .cloneditem-5 {
display: block;
}
}
@media all and (min-width: 992px) and (transform-3d),
all and (min-width: 992px) and (-webkit-transform-3d) {
.carousel-showsixmoveone .carousel-inner > .item.active.right,
.carousel-showsixmoveone .carousel-inner > .item.next {
-webkit-transform: translate3d(16.666%, 0, 0);
transform: translate3d(16.666%, 0, 0);
left: 0;
}
.carousel-showsixmoveone .carousel-inner > .item.active.left,
.carousel-showsixmoveone .carousel-inner > .item.prev {
-webkit-transform: translate3d(-16.666%, 0, 0);
transform: translate3d(-16.666%, 0, 0);
left: 0;
}
.carousel-showsixmoveone .carousel-inner > .item.left,
.carousel-showsixmoveone .carousel-inner > .item.prev.right,
.carousel-showsixmoveone .carousel-inner > .item.active {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
left: 0;
}
}
<!-- begin snippet: js hide: false console: true -->
<!--html-->
<div class="row ">
<div class="col-md-12">
<div class="carousel carousel-showsixmoveone slide" id="chocolatelist" data-interval="30000">
<div class="carousel-inner">
<div class="item active">
<div class="col-xs-12 col-sm-4 col-md-2">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=1" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-1">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=2" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-2">
<a href="#">
<img src="http://placehold.it/500/d6d6d6/333&text=3" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-3">
<a href="#">
<img src="http://placehold.it/500/002040/eeeeee&text=4" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-4">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=5" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-5">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=6" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-4 col-md-2">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=2" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-1">
<a href="#">
<img src="http://placehold.it/500/d6d6d6/333&text=3" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-2">
<a href="#">
<img src="http://placehold.it/500/002040/eeeeee&text=4" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-3">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=5" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-4">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=6" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-5">
<a href="#">
<img src="http://placehold.it/500/eeeeee&text=7" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-4 col-md-2">
<a href="#">
<img src="http://placehold.it/500/d6d6d6/333&text=3" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-1">
<a href="#">
<img src="http://placehold.it/500/002040/eeeeee&text=4" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-2">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=5" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-3">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=6" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-4">
<a href="#">
<img src="http://placehold.it/500/eeeeee&text=7" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-5">
<a href="#">
<img src="http://placehold.it/500/40a1ff/002040&text=8" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-4 col-md-2">
<a href="#">
<img src="http://placehold.it/500/002040/eeeeee&text=4" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-1">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=5" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-2">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=6" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-3">
<a href="#">
<img src="http://placehold.it/500/eeeeee&text=7" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-4">
<a href="#">
<img src="http://placehold.it/500/40a1ff/002040&text=8" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-5">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=1" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-4 col-md-2">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=5" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-1">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=6" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-2">
<a href="#">
<img src="http://placehold.it/500/eeeeee&text=7" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-3">
<a href="#">
<img src="http://placehold.it/500/40a1ff/002040&text=8" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-4">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=1" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-5">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=2" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-4 col-md-2">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=6" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-1">
<a href="#">
<img src="http://placehold.it/500/eeeeee&text=7" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-2">
<a href="#">
<img src="http://placehold.it/500/40a1ff/002040&text=8" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-3">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=1" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-4">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=2" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-5">
<a href="#">
<img src="http://placehold.it/500/d6d6d6/333&text=3" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-4 col-md-2">
<a href="#">
<img src="http://placehold.it/500/eeeeee&text=7" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-1">
<a href="#">
<img src="http://placehold.it/500/40a1ff/002040&text=8" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-2">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=1" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-3">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=2" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-4">
<a href="#">
<img src="http://placehold.it/500/d6d6d6/333&text=3" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-5">
<a href="#">
<img src="http://placehold.it/500/002040/eeeeee&text=4" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-4 col-md-2">
<a href="#">
<img src="http://placehold.it/500/40a1ff/002040&text=8" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-1">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=1" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-2">
<a href="#">
<img src="http://placehold.it/500/002d5a/fff/&text=2" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-3">
<a href="#">
<img src="http://placehold.it/500/d6d6d6/333&text=3" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-4">
<a href="#">
<img src="http://placehold.it/500/002040/eeeeee&text=4" class="img-responsive">
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-2 cloneditem-5">
<a href="#">
<img src="http://placehold.it/500/0054A6/fff/&text=5" class="img-responsive">
</a>
</div>
</div>
</div>
<a class="left carousel-control" href="#chocolatelist" data-slide="prev"><i class="glyphicon glyphicon-chevron-left "></i></a>
<a class="right carousel-control" href="#chocolatelist" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i></a>
</div>
</div>
</div>
paste this code you will get some clue.image link of carousel slide
粘贴这段代码你会得到一些线索。旋转木马幻灯片的图像链接
#11
0
Try this code
<div id="recommended-item-carousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="item active">
<div class="col-sm-3">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<img src="img/home/recommend1.jpg" alt="" />
<h2>$56</h2>
<p>
Easy Polo Black Edition
</p>
<a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
</div>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<img src="img/home/recommend2.jpg" alt="" />
<h2>$56</h2>
<p>
Easy Polo Black Edition
</p>
<a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
</div>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<img src="img/home/recommend3.jpg" alt="" />
<h2>$56</h2>
<p>
Easy Polo Black Edition
</p>
<a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<div class="col-sm-3">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<img src="img/home/recommend1.jpg" alt="" />
<h2>$56</h2>
<p>
Easy Polo Black Edition
</p>
<a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
</div>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<img src="img/home/recommend2.jpg" alt="" />
<h2>$56</h2>
<p>
Easy Polo Black Edition
</p>
<a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
</div>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<img src="img/home/recommend3.jpg" alt="" />
<h2>$56</h2>
<p>
Easy Polo Black Edition
</p>
<a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
</div>
</div>
</div>
</div>
</div>
</div>
<a class="left recommended-item-control" href="#recommended-item-carousel" data-slide="prev"> <i class="fa fa-angle-left"></i> </a>
<a class="right recommended-item-control" href="#recommended-item-carousel" data-slide="next"> <i class="fa fa-angle-right"></i> </a>
</div>
#12
0
I've seen your question and answers, and made a new responsive and flexible multi items carousel Gist. you can see it here:
我看到了你的问题和答案,并作出了一个新的响应和灵活的多项目旋转的要点。你可以在这里看到:
https://gist.github.com/IVIR3zaM/d143a361e61459146ae7c68ce86b066e
https://gist.github.com/IVIR3zaM/d143a361e61459146ae7c68ce86b066e
#13
-1
You can add multiple li in ol tag that has attribute as class with value "carousel-indicators" and with data-slide-to has sequential values like 0 to 6 or 0 to 9.
您可以在ol标记中添加多个li,这些li具有属性为class,具有值“carousell -indicators”和数据条,具有从0到6或从0到9的顺序值。
than you just need to copy and paste the div which has attribute as class with value "item".
您只需要复制和粘贴具有值“项”属性的div。
This works for me.
这适合我。
<div data-ride="carousel" class="carousel slide" id="myCarousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li class="" data-slide-to="0" data-target="#myCarousel"></li>
<li data-slide-to="1" data-target="#myCarousel" class=""></li>
<li data-slide-to="2" data-target="#myCarousel" class="active"></li>
<li data-slide-to="3" data-target="#myCarousel" class=""></li>
<li data-slide-to="4" data-target="#myCarousel" class=""></li>
<li data-slide-to="5" data-target="#myCarousel" class=""></li>
<li data-slide-to="6" data-target="#myCarousel" class=""></li>
</ol>
<div role="listbox" class="carousel-inner">
<div class="item active">
<img alt="First slide" src="images/carousel/11.jpg"
class="first-slide">
</div>
<div class="item">
<img alt="Second slide" src="images/carousel/22.jpg"
class="second-slide">
</div>
<div class="item">
<img alt="Third slide" src="images/carousel/33.jpg"
class="third-slide">
</div>
<div class="item">
<img alt="Third slide" src="images/carousel/44.jpeg"
class="fourth-slide">
</div>
<div class="item">
<img alt="Third slide" src="images/carousel/55.jpg"
class="third-slide">
</div>
<div class="item">
<img alt="Third slide" src="images/carousel/66.jpg"
class="third-slide">
</div>
<div class="item">
<img alt="Third slide" src="images/carousel/77.jpg"
class="third-slide">
</div>
</div>
<a data-slide="prev" role="button" href="#myCarousel"
class="left carousel-control"> <span aria-hidden="true"
class="glyphicon glyphicon-chevron-left"></span> <span
class="sr-only">Previous</span>
</a> <a data-slide="next" role="button" href="#myCarousel"
class="right carousel-control"> <span aria-hidden="true"
class="glyphicon glyphicon-chevron-right"></span> <span
class="sr-only">Next</span>
</a>
</div>