How to Create a Carousel using Bootstrap and jQuery
Submitted by nurhodelta_17 on Saturday, January 27, 2018 - 22:58.
Adding Dependency
First, we are going to add the dependencies for the carousel to work and in this tutorial, I've used CDN so you need internet connection for them to work. Include the ff dependecies in header for the Boostrap 3.3.7 CSS or you can put the jQuery and Bootstrap 3.3.7 JS at the bottom of body tag. Note: Always declare jQuery first than your Bootstrap JS since Bootstrap JS needs jQuery for some of its functions.Add the Carousel
Next we add the whole Carousel on our body. The place where you want to put this is up to you.- <div id="myCarousel" class="carousel slide" data-ride="carousel">
- <!-- Indicators -->
- <ol class="carousel-indicators">
- </ol>
- <!-- Items -->
- <div class="carousel-inner">
- <div class="item active">
- <img src="img/1.jpg" alt="First Image">
- <div class="carousel-caption">
- </div>
- </div>
- <div class="item">
- <img src="img/2.jpg" alt="Second Image">
- <div class="carousel-caption">
- </div>
- </div>
- <div class="item">
- <img src="img/3.jpg" alt="Third Image">
- <div class="carousel-caption">
- </div>
- </div>
- <div class="item">
- <img src="img/4.jpg" alt="Fourth Image">
- <div class="carousel-caption">
- </div>
- </div>
- </div>
- <!-- Controls -->
- <a class="left carousel-control" href="#myCarousel" data-slide="prev">
- </a>
- <a class="right carousel-control" href="#myCarousel" data-slide="next">
- </a>
- </div>
Active Indicator:
That ends this tutorial. Happy Coding :)
Add new comment
- 213 views