Bootstrap 4 | Carousel
The Bootstrap Carousel is used to create an image slide show for the webpage to make it look more attractive. It can be included in the webpage using bootstrap.js or bootstrap.min.js. Carousels are not supported properly in Internet Explorer, this is because they use CSS3 transitions and animations to achieve the slide effect.
Example:
<!DOCTYPE html> <html lang="en"> <head> <title>Carousel</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href= <script src= </script> <script src= </script> <script src= </script> <style> /* Make the image fully responsive */ .carousel-inner img { width: 100%; height: 100%; } </style> </head> <body> <div id="GFG" class="carousel slide" data-ride="carousel"> <!-- Indicators --> <ul class="carousel-indicators"> <li data-target="#GFG" data-slide-to="0" class="active"></li> <li data-target="#GFG" data-slide-to="1"></li> <li data-target="#GFG" data-slide-to="2"></li> <li data-target="#GFG" data-slide-to="3"></li> </ul> <!-- The slideshow --> <div class="carousel-inner"> <div class="carousel-item active"> <img src= alt="GFG" width="600" height="400"> </div> <div class="carousel-item"> <img src= alt="GFG" width="600" height="600"> </div> <div class="carousel-item"> <img src= alt="GFG" width="600" height="400"> </div> <div class="carousel-item"> <img src= alt="GFG" width="600" height="400"> </div> </div> <a class="carousel-control-prev" href="#GFG" data-slide="prev"> <span class="carousel-control-prev-icon"></span> </a> <a class="carousel-control-next" href="#GFG" data-slide="next"> <span class="carousel-control-next-icon"></span> </a> </div> </body> </html> |
Output:

Add Captions to Slides: Use .carousel-caption inside .carousel-item class is used to add caption to the slide.
Example:
<!DOCTYPE html> <html lang="en"> <head> <title>Carousel</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href= <script src= </script> <script src= </script> <script src= </script> <style> /* Set the image size */ .carousel-inner img { width: 100%; } </style> </head> <body> <div id="GFG" class="carousel slide" data-ride="carousel"> <!-- Indicators --> <ul class="carousel-indicators"> <li data-target="#GFG" data-slide-to="0" class="active"></li> <li data-target="#GFG" data-slide-to="1"></li> <li data-target="#GFG" data-slide-to="2"></li> </ul> <!-- The slideshow --> <div class="carousel-inner"> <div class="carousel-item active"> <img src= alt="GFG" width="600" height="400"> <div class="carousel-caption"> <h3 class="text-warning"> GeeksforGeeks: Interview Preparation Caption </h3> </div> </div> <div class="carousel-item"> <img src= alt="GFG" width="600" height="400"> <div class="carousel-caption"> <h3 class="text-warning"> GeeksforGeeks: Geeks Classes Caption </h3> </div> </div> <div class="carousel-item"> <img src= alt="GFG" width="600" height="400"> <div class="carousel-caption"> <h3 class="text-warning"> GeeksforGeeks: Geeks Classes Caption </h3> </div> </div> </div> <a class="carousel-control-prev" href="#GFG" data-slide="prev"> <span class="carousel-control-prev-icon"></span> </a> <a class="carousel-control-next" href="#GFG" data-slide="next"> <span class="carousel-control-next-icon"></span> </a> </div> </body> </html> |
Output:

Recommended Posts:
- Bootstrap | Carousel
- How to display bootstrap carousel with three post in each slide?
- Include Bootstrap in AngularJS using ng-bootstrap
- Clearfix in Bootstrap
- Bootstrap | Spinners Set-2
- Bootstrap | Spinners Set-1
- Bootstrap 4 | Colors
- Bootstrap 4 | Jumbotron
- Bootstrap 4 | Alerts
- Bootstrap 4 | Badges
- Bootstrap 4 | Images
- Bootstrap 4 | Tables
- Bootstrap 4 | Spinners
- Bootstrap 4 | Buttons
- Bootstrap 4 | Dropdowns
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



