2

I am trying to use bootstrap 4.1 in a new web project. On the main page of my project, I want to show the users a carousel with multiple html dividers.

The end result should look like something like the following picture enter image description here

When a user clicks the previous/next buttons, the carousel advances one HTML divider toward the corresponding direction.

I found slick-carousel plugin which seems to do exactly what I am looking for. But, I am hesitating into adding yet another library in my project. To avoid adding another library, I am hoping to be able to utilize Bootstrap 4.1 own Carousel to get a similar result.

The code snippet found in this link shows the slick-carousel plugin in action configured to how I wish the carousel behave on my site.

How can I configure twitter-bootstrap 4.1 owns carousel to do the same thing

I tried to configure Bootstrap's carousel as follow https://www.codeply.com/go/gF4VnWfIAW

<div class="jumbotron bg-primary">
    <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
      <div class="carousel-inner">
        <div class="carousel-item text-center active">

            <div class="card" style="width: 18rem;">
              <div class="card-body">
                <h5 class="card-title">First</h5>
                <p class="card-text">First Block</p>
              </div>
            </div>

        </div>
        <div class="carousel-item text-center">


            <div class="card" style="width: 18rem;">
              <div class="card-body">
                <h5 class="card-title">Second</h5>
                <p class="card-text">Second Block</p>
              </div>
            </div>

       </div>
        <div class="carousel-item text-center">


            <div class="card" style="width: 18rem;">
              <div class="card-body">
                <h5 class="card-title">Third</h5>
                <p class="card-text">Third Block</p>
              </div>
            </div>

        </div>
      </div>
      <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
      </a>
      <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
      </a>
    </div>
</div>

However, the above code has two issues

  1. It only shows one block/card at a time. I want to show 3 blocks at the same time and every time shift one block at a time.
  2. It auto play which is something I don't want. I want to move one block when the user clicks the previous/next button.

How can I configure the bootstrap's carousel to show 3 card and slide one card at a time on click?

Junior
  • 11,602
  • 27
  • 106
  • 212
  • This work?: https://codepen.io/mephysto/pen/ZYVKRY – UnpassableWizard Oct 29 '18 at 23:07
  • @Rustyjim that would work for bootstrap 3. I need it to work for Bootstrap 4.1 which it does not https://www.codeply.com/go/x3aMXl1Cgk Here is another once from the marked duplicate answer which also does not work https://www.codeply.com/go/abl0iCMUOE – Junior Oct 30 '18 at 04:45
  • Did you read and understand both question and answers? For example, what's wrong with: https://www.codeply.com/go/SgN7j7h4dV – Carol Skelly Oct 30 '18 at 11:04

0 Answers0