I am trying out Twitter bootstrap 3. I am quite new to HTML, CSS and Javascript. I have a carousel which i created and it's code looks like so:
<div class="container">
<div id="myCarousel2" class="carousel slide">
<!-- Carousel items -->
<div class="carousel-inner">
<div class="item active">
<div class="row text-center">
<!-- ITEM-->
<div class="col-md-3">
<div class="thumbnail product-item"> <a class="img-responsive" href="/current-buzz"><img src="{% static 'img/buzzbutton.jpg' %}"/></a>
</div>
</div>
<!-- ITEM-->
<!-- ITEM-->
<div class="col-md-3">
<div class="thumbnail product-item"> <a class="img-responsive" href="/current-buzz"><img src="{% static 'img/recipebutton.jpg' %}"/></a>
</div>
</div>
<!-- ITEM-->
<!-- ITEM-->
<div class="col-md-3">
<div class="thumbnail product-item"> <a class="img-responsive" href="/current-buzz"><img src="{% static 'img/buzzbutton.jpg' %}"/></a>
</div>
</div>
<!-- ITEM-->
<!-- ITEM-->
<div class="col-md-3">
<div class="thumbnail product-item"> <a class="img-responsive" href="/current-buzz"><img src="{% static 'img/recipebutton.jpg' %}"/></a>
</div>
</div>
<!-- ITEM-->
</div>
</div>
<div class="item">
<div class="row text-center">
<!-- ITEM-->
<div class="col-md-3">
<div class="thumbnail product-item"> <a class="img-responsive" href="/current-buzz"><img src="{% static 'img/buzzbutton.jpg' %}"/></a>
</div>
</div>
<!-- ITEM-->
<!-- ITEM-->
<div class="col-md-3">
<div class="thumbnail product-item"> <a class="img-responsive" href="/current-buzz"><img src="{% static 'img/recipebutton.jpg' %}"/></a>
</div>
</div>
<!-- ITEM-->
<!-- ITEM-->
<div class="col-md-3">
<div class="thumbnail product-item"> <a class="img-responsive" href="/current-buzz"><img src="{% static 'img/buzzbutton.jpg' %}"/></a>
</div>
</div>
<!-- ITEM-->
<!-- ITEM-->
<div class="col-md-3">
<div class="thumbnail product-item"> <a class="img-responsive" href="/current-buzz"><img src="{% static 'img/recipebutton.jpg' %}"/></a>
</div>
</div>
<!-- ITEM-->
</div>
</div>
</div>
<!-- /INNER-->
<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel2" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i></a>
</div>
</div>
Now this is set to show 4 images at a time. The thing is I have 8 images. In the carousel above it displays 4 images at a time and then slides to the next 4. Here's the Javascript:
<script type="text/javascript">
$('.carousel.slide').carousel()
</script>
And the CSS:
@media (max-width: 767px){
.carousel .row .span3 {
display: block;
float: left;
width: 25%;
margin-left: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
}
.carousel .carousel-control { visibility: hidden; }
How do I get the images to move only one-at-a-time in a continuous loop?
Take a look at this Bootply: http://bootply.com/94452
You can use jQuery to clone() the items accordingly..
$('.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));
}
});
Alternative option: Bootstrap carousel multiple frames at once
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With