Jeffrey Payne
Jeffrey Payne

Reputation: 23

Bootstrap carousel photos list not working

I'm currently trying to add a bootstrap carousel to this website in which I'm making for someone and every time I add a photo or a caption, the photos either line up in a list and the captions stack up on top of each other. Can someone help ?

This is what the website looks like:

Photos stacked on top of each other:

enter image description here

What the caption looks like with a <h3> and a <h4> string:

enter image description here

This is the bit of code (I used the template that bootstrap has on their website):

<section class="container">
      <div class="row">
        <div class="col-sm-12">
          <div id="my-slider" class="carousel slide col-sm-12" data-ride="carousel">
            <!-- indicators -->
            <ol class="carousel-indicators">
              <li data-target="#my-slide" data-slide-to="0" class="active"></li>
              <li data-target="#my-slide" data-slide-to="1"></li>
              <li data-target="#my-slide" data-slide-to="2"></li>
              <li data-target="#my-slide" data-slide-to="3"></li>
            </ol>
            <!-- wrappers -->
            <div class="carousel-inner" role="listbox">
              <div class="item active">
                <img src="" alt=""/>
                <div class="carousel-caption">
                    <h3>Flutes of the World Concert</h3>
                    <h5>with Tereasa Payne</h5>
                </div>
              </div>
              <div class="item">
                  <img id="img" src="img/RPO_Siku.jpg" alt="siku"/>
                  <div class="carousel-caption">
                    <h4></h4>
                    <h5></h5>
                  </div>
                </div>
                <div class="item">
                  <img id="img" src="img/RPO_Nose_Flute_Laughing.jpg" alt=""/>
                  <div class="carousel-caption">
                    <h4></h4>
                    <h5></h5>
                  </div>
                </div>
                <div class="item">
                  <img id="img" src="img/RPO_playing_Toyo.jpg" alt=""/>
                  <div class="carousel-caption">
                    <h4></h4>
                    <h5></h5>
                  </div>
                </div>
                <div class="item">
                    <img src="img/RPO_Native_American_Flute.jpg" alt=""/>
                    <div class="carousel-caption">
                      <h4></h4>
                      <h5></h5>
                    </div>
                  </div>
            </div>
            <!-- controls -->
            <a class="left carousel-control" href="#my-slider" role="button" data-slide="prev">
              <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
              <span class="sr-only">Previous</span>
            </a>
            <a class="right carousel-control" href="#my-slider" role="button" data-slide="next">
                <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                <span class="sr-only">Next</span>
            </a>
          </div>
        </div>
      </div>
    </section>

Upvotes: 1

Views: 108

Answers (2)

Bourbia Brahim
Bourbia Brahim

Reputation: 14702

In bootstrap 4 every slide should have a class carousel-item not item as bootstrap 3 ,

also as @WebDevbooster mentiened boostrap 4 does not inlude font awsome so for you control use carousel-control-prev for prev control and carousel-control-next for next :

See below working snippet :

.carousel-inner img {
      width: 100%;
      height: 100%;
  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>

<section class="container">
      <div class="row">
        <div class="col-sm-12">
          <div id="my-slider" class="carousel slide" data-ride="carousel">
            <!-- indicators -->
            <ol class="carousel-indicators">
              <li data-target="#my-slider" data-slide-to="0" class="active"></li>
              <li data-target="#my-slider" data-slide-to="1"></li>
              <li data-target="#my-slider" data-slide-to="2"></li>
              <li data-target="#my-slider" data-slide-to="3"></li>
            </ol>
            <!-- wrappers -->
            <div class="carousel-inner" role="listbox">
              
              <div class="carousel-item active">
                  <img id="img" src="https://www.w3schools.com/bootstrap4/chicago.jpg" alt="siku"/>
                  <div class="carousel-caption">
                    <h4></h4>
                    <h5></h5>
                  </div>
                </div>
                <div class="carousel-item">
                  <img id="img" src="https://www.w3schools.com/bootstrap4/ny.jpg" alt=""/>
                  <div class="carousel-caption">
                    <h4></h4>
                    <h5></h5>
                  </div>
                </div>
                <div class="carousel-item">
                  <img id="img" src="https://www.w3schools.com/bootstrap4/la.jpg" alt=""/>
                  <div class="carousel-caption">
                    <h4></h4>
                    <h5></h5>
                  </div>
                </div>
                <div class="carousel-item">
                    <img src="https://www.w3schools.com/bootstrap4/la.jpg" alt=""/>
                    <div class="carousel-caption">
                      <h4></h4>
                      <h5></h5>
                    </div>
                  </div>
            </div>
            <!-- controls -->
              <!-- Left and right controls -->
  <a class="carousel-control-prev" href="#my-slider" data-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </a>
  <a class="carousel-control-next" href="#my-slider" data-slide="next">
    <span class="carousel-control-next-icon"></span>
  </a>
          </div>
        </div>
      </div>
    </section>

Upvotes: 1

WebDevBooster
WebDevBooster

Reputation: 14954

Nesting Bootstrap columns directly inside other Bootstrap columns is NOT allowed.

Bootstrap columns must always have a Bootstrap row as a parent.

Reference:

https://getbootstrap.com/docs/4.0/layout/grid/#nesting

https://getbootstrap.com/docs/4.0/components/carousel/#with-captions

Also, there are no glyphicons in Bootstrap 4.

Upvotes: 0

Related Questions