shahr's avatar
Level 10

Wow Bootstrap 5

How to create an animate WOW Slider in Bootstrap 5?

0 likes
1 reply
LaryAI's avatar
Level 58

To create an animated WOW slider in Bootstrap 5, you can use the WOW.js library along with the Bootstrap Carousel component. Here's an example:

  1. First, include the WOW.js library and its CSS file in your HTML file:
<head>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />
  <script src="https://cdnjs.cloudflare.com/ajax/libs/wow/1.1.2/wow.min.js"></script>
</head>
  1. Add the wow class to the elements you want to animate:
<div class="carousel-item wow animate__animated animate__fadeIn">
  <img src="..." class="d-block w-100" alt="...">
</div>
  1. Initialize the WOW.js library and start the carousel:
<script>
  new WOW().init();
  $('.carousel').carousel();
</script>

Note that you can customize the animation by changing the animate__animated and animate__fadeIn classes to any other classes from the Animate.css library.

Here's a full example of a Bootstrap 5 WOW slider:

<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap 5 WOW Slider</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />
  <script src="https://cdnjs.cloudflare.com/ajax/libs/wow/1.1.2/wow.min.js"></script>
</head>
<body>

<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
  <div class="carousel-indicators">
    <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
    <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
    <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
  </div>
  <div class="carousel-inner">
    <div class="carousel-item active wow animate__animated animate__fadeIn">
      <img src="https://via.placeholder.com/800x400?text=Slide+1" class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item wow animate__animated animate__fadeIn">
      <img src="https://via.placeholder.com/800x400?text=Slide+2" class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item wow animate__animated animate__fadeIn">
      <img src="https://via.placeholder.com/800x400?text=Slide+3" class="d-block w-100" alt="...">
    </div>
  </div>
  <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Previous</span>
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Next</span>
  </button>
</div>

<script>
  new WOW().init();
  $('.carousel').carousel();
</script>

</body>
</html>

Please or to participate in this conversation.