Online: 13992
Wrap function in Carousel is used continous sliding of image and stops sliding after last image, we can warp using data-attribute and javascript
<style>
.carousel-inner > .item > img,
.carousel-inner > .item > a > img {
width: 70%;
margin: auto;
}
</style>
</head>
<body>
<div class="container">
<h2>Carousel wrap</h2>
<div id="myCarousel" class="carousel slide">
<ol class="carousel-indicators">
<li class="item1 active"></li>
<li class="item2"></li>
<li class="item3"></li>
<li class="item4"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="apple-01.jpg" height="200" width="100" />
</div>
<div class="item">
<img src="download.jpg" height="200" width="100"/>
</div>
<div class="item">
<img src="images%20(1).jpg" height="200" width="100" />
</div>
<div class="item">
<img src="images.jpg" height="200" width="100"/>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" role="button">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<script>
$(document).ready(function () {
$("#myCarousel").carousel({ interval: 500, wrap: false });
$(".item1").click(function () {
$("#myCarousel").carousel(0);
});
$(".item2").click(function () {
$("#myCarousel").carousel(1);
});
$(".item3").click(function () {
$("#myCarousel").carousel(2);
});
$(".item4").click(function () {
$("#myCarousel").carousel(3);
});
$(".left").click(function () {
$("#myCarousel").carousel("prev");
});
$(".right").click(function () {
$("#myCarousel").carousel("next");
});
});
</script>
</body>
container and we have another div with id as mycarousel and class value as carousel slide.carousel-indicators to define the list values carousel-inner and role as list box and we have defined the sliding images using class value item left and right carousel control defining the glyphicon of left and right symbols#mycarousel and data-interval as 500 and , wrap as false defines the continous sliding of the image and makes stop at the last image by defining the item values output
Carousel wrap is used to make the images slide continously and make stop after last image, in this we are using carousel wrap with data-attribute
<style>
.carousel-inner > .item > img,
.carousel-inner > .item > a > img {
width: 70%;
margin: auto;
}
</style>
</head>
<body>
<div class="container">
<div id="#mycarousel" class="carousel slide" data-wrap="false" data-interval="500" data-ride="carousel">
<h2>Bootstrap carousel slide with wrap using data-attribute</h2>
<ol class="carousel-indicators">
<li data-target="#mycarousel" data-slide="0" class="active"></li>
<li data-target="#mycarousel" data-slide="1"></li>
<li data-target="#mycarousel" data-slide="2"></li>
<li data-target="#mycarousel" data-slide="3"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="apple-01.jpg" height="200" width="100" />
</div>
<div class="item">
<img src="download.jpg" height="200" width="100" />
</div>
<div class="item">
<img src="images%20(1).jpg" height="200" width="100" />
</div>
<div class="item">
<img src="images.jpg" height="200" width="100" />
</div>
</div>
<a class="left carousel-control" href="#mycarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only"></span>
</a>
<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"></span>
</a>
</div>
</div>
</body>
container and we have defined the div with id as #mycarousel and class value as carousel slide and data-wrap as false defines the wrap function<ol> element with class value as carousel-indicators to define the list values with data-slide valuescarousel-inner to define the images and left and right symbolsoutput
Views: 14819 | Post Order: 46