Simple Carousel using Bootstrap/Javascript

Language

This tutorial will show you how to create a simple carousel using Bootstrap and Javascript. In this tutorial, I've prepared sample pictures that we are going to use in our carousel. To start with, let's create our slide page. This is the page that will show our images in a slider. Also included on the page, are the scripts used to make the slider. To create the page, open your HTML code editor and paste the code below after the tag. We name our page as "index.php".
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <meta charset="utf-8">
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <meta name="description" content="">
  7. <meta name="author" content="">
  8. <title>Carousel Example</title>
  9. <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  10. .sample_slide{
  11. width:1000px;
  12. margin-left:50px;
  13. margin-top:50px;
  14. }
  15. <div id="myCarousel" class="carousel slide sample_slide">
  16. <!-- Carousel items -->
  17. <div class="carousel-inner">
  18. <div class="active item"><img src="img/1.jpeg" height="250px"></div>
  19. <div class="item"><img src="img/2.jpeg" height="250px"></div>
  20. <div class="item"><img src="img/3.jpeg" height="250px"></div>
  21. <div class="item"><img src="img/5.jpeg" height="250px"></div>
  22. <div class="item"><img src="img/6.jpeg" height="250px"></div>
  23. </div>
  24. <!-- Carousel nav -->
  25. <a class="carousel-control left" href="#myCarousel" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i></a>
  26. <a class="carousel-control right" href="#myCarousel" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i></a>
  27. </div>
  28.  
  29. <script src="vendor/jquery/jquery.min.js"></script>
  30. <script src="vendor/bootstrap/js/bootstrap.min.js"></script>
  31. <script type="text/javascript">
  32. $(function(){
  33. $('#myCarousel').carousel({interval:4000});
  34. });
  35. </script>
  36. </body>
  37. </html>
The script and bootstrap are included in the code file of this tutorial.

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment