Skip to content

Instantly share code, notes, and snippets.

@IVIR3zaM
Last active September 12, 2021 04:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save IVIR3zaM/d143a361e61459146ae7c68ce86b066e to your computer and use it in GitHub Desktop.
Save IVIR3zaM/d143a361e61459146ae7c68ce86b066e to your computer and use it in GitHub Desktop.
Responsive Multi Item Carousel in Bootstrap 3 (a fork of https://codepen.io/mephysto/pen/ZYVKRY and optimized for responsive design and flexible active items)
<!--
There is:
1 active items in extra small screens
2 active items in small screens
3 active items in medium screens
4 active items in large screens
-->
<div class="carousel slide multi-item-carousel xs-items-1 sm-items-2 md-items-3 lg-items-4" id="sample1">
<div class="carousel-inner">
<div class="item active">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
<a href="#">
<img src="http://placehold.it/300/f44336/000000" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
<a href="#">
<img src="http://placehold.it/300/e91e63/000000" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
<a href="#">
<img src="http://placehold.it/300/9c27b0/000000" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
<a href="#">
<img src="http://placehold.it/300/673ab7/000000" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
<a href="#">
<img src="http://placehold.it/300/4caf50/000000" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
<a href="#">
<img src="http://placehold.it/300/8bc34a/000000" class="img-responsive">
</a>
</div>
</div>
</div>
<a class="left carousel-control" href="#sample1" data-slide="prev">
<i class="glyphicon glyphicon-chevron-left"></i>
</a>
<a class="right carousel-control" href="#sample1" data-slide="next">
<i class="glyphicon glyphicon-chevron-right"></i>
</a>
</div>
<!--
There is:
3 active items in extra small and small screens
4 active items in medium screens
6 active items in large screens
-->
<div class="carousel slide multi-item-carousel xs-items-3 md-items-4 lg-items-6" id="sample2">
<div class="carousel-inner">
<div class="item active">
<div class="col-xs-4 col-md-3 col-lg-2">
<a href="#">
<img src="http://placehold.it/300/f44336/000000" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-4 col-md-3 col-lg-2">
<a href="#">
<img src="http://placehold.it/300/e91e63/000000" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-4 col-md-3 col-lg-2">
<a href="#">
<img src="http://placehold.it/300/9c27b0/000000" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-4 col-md-3 col-lg-2">
<a href="#">
<img src="http://placehold.it/300/673ab7/000000" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-4 col-md-3 col-lg-2">
<a href="#">
<img src="http://placehold.it/300/4caf50/000000" class="img-responsive">
</a>
</div>
</div>
<div class="item">
<div class="col-xs-4 col-md-3 col-lg-2">
<a href="#">
<img src="http://placehold.it/300/8bc34a/000000" class="img-responsive">
</a>
</div>
</div>
</div>
<a class="left carousel-control" href="#sample2" data-slide="prev">
<i class="glyphicon glyphicon-chevron-left"></i>
</a>
<a class="right carousel-control" href="#sample2" data-slide="next">
<i class="glyphicon glyphicon-chevron-right"></i>
</a>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment