Issue with displaying images in Bootstrap carousel

I'm facing a challenge with integrating a bootstrap carousel into a website project I'm customizing for a client. Despite my efforts to add photos and captions, the images are aligning in a list format and the captions are stacking on top of each other. Can someone provide guidance on resolving this issue?

Here is a visual representation of the problem:

Stacked photos:

https://i.sstatic.net/Wtsfk.jpg

An example of a caption with <h3> and <h4> elements:

https://i.sstatic.net/PPBbv.jpg

Below is the section of code I've utilized from the Bootstrap template:

<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>

Answer №1

When using Bootstrap 4, each slide should be assigned the class carousel-item instead of item like in Bootstrap 3,

Additionally, as noted by @WebDevbooster, Bootstrap 4 no longer includes Font Awesome icons. To add control buttons, use carousel-control-prev for the previous control and carousel-control-next for the next control :

Below is a functioning snippet showcasing this:

.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>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

CSS Alignment in React with Material UI

Is there a way to align one button to the left while centering the other two? To see an example in Codesandbox, please visit HERE <DialogActions sx={{ justifyContent: "center" }}> <Button>Left</Button> <Button on ...

Creating a dynamic search feature that displays results from an SQL database with a dropdown box

Is there a way to create a search bar similar to those seen on popular websites like YouTube, where the search results overlay the rest of the page without displacing any content? I've searched extensively on Google and YouTube for tutorials on databa ...

Guide to automatically triggering overscrolling

Currently working on a kiosk webpage designed for an iPad. Discovered an app that enables fullscreen mode, but requires overscrolling at the bottom. Is there a method to automatically trigger this on my webpage? Attempted to achieve this using autoscroll ...

Do you have any tips on designing a mobile-friendly navigation bar?

Struggling with creating a responsive navbar using Bootstrap 5? The navbar-brand is causing issues with letters overflowing over other elements, and the toggle-icon is not aligning properly. Check out my Codepen for reference: https://codepen.io/namename12 ...

HTML min-width is not being considered by the media query breakpoint

After resizing the browser window to less than 480px, my site reverts back to its original style (the css not defined inside the mixins). I attempted to limit the html with min-width, but despite the browser displaying a horizontal scrollbar, the css still ...

The alignment of Div elements is off in IE8

I have been struggling to align two divs side by side without any empty spaces on IE 8. Everything looks perfect on Chrome Version 35.0.1916.153 m and Firefox 30.0, but IE 8 seems to be causing some issues. All I want is a main div with two child divs ali ...

The website is not optimized for mobile viewing

I have recently made an existing website responsive using Twitter Bootstrap. Everything seemed to work fine when I tested it by resizing the browser window, as it perfectly fit in the viewport. However, upon checking the site on mobile and tablet devices, ...

Implementing JavaScript to add elements to class

Is there a way to use JavaScript to dynamically add classes to elements? <div class="col-md-4 col-xs-6 work-item web-design" id="SetCategory"> . . <script> document.getElementById("SetCategory").classList.add('{{ $category->nam ...

I'm seeking guidance on how to delete a specific ul li element by its id after making an ajax request to delete a corresponding row in MySQL database. I'm unsure about the correct placement for the jQuery

I have created an app that displays a list of income items. Each item is contained within an li element with a unique id, along with the item description and a small trash icon. Currently, I have implemented code that triggers an AJAX call when the user cl ...

Revamp responsiveness in bootstrap 3 for printing with @media queries

My goal is to disable the responsive features of bootstrap when the event javascript:print() is triggered. This way, I want my webpage to maintain the column grid layout that I have defined, regardless of screen size. One solution suggested in this answer ...

revealing the excessive vertical space in the div upon clicking the link

Here is the structure: +-----------------------------------------------------------------------+ | | | heading {position: fixed;} | |________ ...

Creating a centered div in HTML for WordPress

<div id="logo" style="center"><img src="logo1.png"></img></div><br><br><br><br><br><br><br></div> It seems like there is an issue with the styling of the div element. The syntax might ...

Using the power of Selenium's XPath, we can easily navigate through a table to access

Looking for assistance in creating selenium xpath for the various column links within a table. Each row has a unique identifier and contains information about a product, including the name. Based on the product name, I need to locate other links within the ...

Issues with navigation menus in Bootstrap/Wordpress

My mobile drop-down menu is giving me some strange issues. When you toggle the button, the menu briefly appears just below the button before moving to its correct position. Sometimes it doesn't work at all, and clicking has no effect. You can witnes ...

Toggle the backgroundImage visibility by setting it to either hidden or displayed using jquery

$('.arrow').css("background-image", "url('../img/arrow.png')").hide(); I have implemented a custom solution using CSS and jQuery to hide the downward arrow when scrolling down on my webpage. `$( document ).ready(function() {
 co ...

The alignment of my text appears to be off

I am facing an issue with the second <ul> on my webpage, which contains more content compared to the first one. In this second <ul>, the last line is appearing floated to the left and does not appear below the penultimate line as expected. Li ...

Maintain the HTML font color when printing - Issue with IE settings, not the printer

I've been struggling with this issue all day. Initially, I thought it was a problem with the print settings, but then I realized that it's actually the "Print background colors and images" option in IE causing the trouble. Here is the last test ...

Is it possible to implement Photoshop-inspired color curves filters on an HTML tag?

I am attempting to recreate the color curves filter from Photoshop using an HTML video tag. https://i.stack.imgur.com/erB1C.png The solution closest to what I need so far is how to simulate Photoshop's RGB levels with CSS and SVG Filters, but it doe ...

Easy jQuery image that smoothly fades in and out

Can anyone recommend a script that allows for creating a slideshow where images fade in and out, rather than sliding left and right? I have a list of images below that I would like to use for the slideshow. <ul class="slideshow"> <li><im ...

Steps for setting the value of a textbox within a bootstrap popover

When a user clicks on an Anchor element, I am displaying a Bootstrap popover using the following JQuery code. Jquery $("[data-toggle=popover]").popover({ trigger: 'click', placement: "top", html: true, ...