Can someone help me troubleshoot my Bootstrap carousel code?

Currently enrolled in Angela Yu's Web Development Course, I am delving into Bootstrap carousels. After successfully testing the code on Codeply, I transferred it to my own HTML document only to find that the next and previous buttons were no longer functional. Visually, they appeared distorted with strange borders and backgrounds. Despite consulting the Bootstrap documentation, I couldn't pinpoint the cause of this issue. Any assistance would be greatly appreciated.

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <title>Title</title>
  <!-- jQuery -->
  ...
  <script src="https://kit.fontawesome.com/3f441d9c50.js" crossorigin="anonymous"></script>
</head>

<body>
<section id="testimonials">
<div id="testimonial-carousel" class="carousel slide" data-bs-ride="false">
      ...
 </button>
    </div>
</section>
</body>
body {
  ...
}

h1 {
  ...
}

h2 {
  ...
}

.container-fluid {
  ...
}

...

https://i.sstatic.net/FJv2J.png

Edit: The issue stemmed from using Bootstrap 4 code with Bootstrap 5 implementation. Resolved now.

Answer №1

If you're looking to implement a Bootstrap version 4.x carousel, the code should be structured as follows:

<div id="testimonial-carousel" class="carousel slide" data-ride="false">
          <div class="carousel-inner">
            <div class="carousel-item active">
              <h2> I no longer have to sniff other dogs for love. I've found the hottest Corgi on
                TinDog. Woof. </h2>
              <img class="testimonial-image" src="https://www.w3schools.com/bootstrap5/la.jpg" alt="dog-profile" />
              <em>Pebbles, New York</em>
            </div>
            <div class="carousel-item">
              <h2 class="testimonial-text">My dog used to be so lonely, but with TinDog's help, they've
                found the love of their life. I think.</h2>
              <img class="testimonial-image" src="https://www.w3schools.com/bootstrap5/ny.jpg" alt="lady-profile">
              <em>Beverly, Illinois</em>
            </div>
          </div>
          <button class="carousel-control-prev" type="button" href="#testimonial-carousel" data-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" href="#testimonial-carousel" data-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"></span>
            <span class="visually-hidden">Next</span>
     </button>
        </div>

Make sure to use href= for buttons instead of data-target=

Remove -bs- wherever it was added in the code (e.g., data-bs-ride="false")

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

Create a list item that includes an image with a corresponding label positioned beneath it

Currently attempting to convert my design into HTML and CSS for the first time, I've hit a roadblock with this particular task: I'm trying to create a series of white boxes, with each item having a white border. However, I'm struggling to c ...

Pass data from Action Class to ajax using JSON syntax

Currently I am facing an issue while working on fullCalendar, a jQuery plugin. I am trying to populate event details from a database when the Calendar page loads, but I seem to be stuck with a silly problem that I can't figure out. $('#calendar& ...

What is the process for obtaining a JSON result after completing an upload?

I recently started working with the razor view engine and I have encountered a situation where I need to upload an image using the Change event of an image browser. The jQuery function for this task is as follows: $("#billUpload").change(function (){ ...

Use jQuery to retrieve the response from a JSON request and showcase it on the existing HTML page

Currently, I am working on a project that involves integrating a JSON-based web service from a remote server. The method of this service can be accessed by using specially formatted URLs such as: http://root-url/ws/service-name?request={json-string} The ...

Unable to retrieve file paths for assets using Node.js Server and Three.js

I am facing challenges when it comes to loading 3D models from a folder on my computer using a localhost node.js test server with the three.js library. Below is my app.js file that I execute via command line in the project directory using the 'node a ...

Guide to incorporating a shiny application into an Rmarkdown HTML file

Currently, I am trying to craft an HTML document using RMarkdown that includes text, R code, and a Shiny application embedded within it. In my attempts, I considered using the asis=TRUE for the shinyApp(ui, server) block. However, I discovered that RStud ...

Using Angular 4 for HTML 5 Drag and Drop functionality

I have been working on integrating native HTML 5 drag & drop functionality into my angular application. While I have successfully implemented the drag and dragOver events, I am facing an issue with the drop event not firing as expected. Here is the snipp ...

Ways to make Joomla! send emails in HTML format

I am knowledgeable about using Joomla! with phpMailer for sending emails. I understand that in order to send emails in HTML format, the following code must be used: $mailer->isHTML(true); However, this approach requires editing the source code of defa ...

Leveraging JQuery to extract the numerical value located between the slashes within a hyperlink

I need to extract numeric values from a link like this. For example: /produkt/114664/bergans-of-norway-airojohka-jakke-herre In this case, I want to fetch 114664. To achieve this, I have written the following jQuery code: jQuery(document).ready(functi ...

Increase value by 1 with the push of a button within two specified ranges using JavaScript

I am looking to create buttons that will increase the value of both the first and second range by 1 when pressed, as well as decrease the value of both ranges by 1 when pressed. Here is my code: function run(){ var one = document.getElementById("rang ...

The Art of Revealing an Element

Is it possible to manipulate a parent div element in JavaScript without affecting its child nodes? For example, transforming this structure: <div class="parent"> <div class="child"> <div class="grandchil ...

Attempting to showcase a button element within a popover, although it is failing to appear

I have implemented a feature where a popover appears when hovering over an inbox icon (font-awesome). However, I am facing an issue with displaying a button on the second row within the popover. The title is showing up fine, but the button is not appearing ...

What sets npm node-sass apart from npm sass?

Recently, I discovered that the recommended approach is to utilize @use rather than @import in sass. However, it appears that using npm sass instead of npm node-sass is necessary for this. Can you clarify the distinction between these two? Also, why do @ ...

Arrange the element as though it were the foremost

My specific scenario is as follows: <div id="container"> <p id="first">...</p> <p id="second">...</p> </div> I am looking to rearrange the order of second and first within the HTML stru ...

Redirecting to the homepage with ScrollTop feature

With the development of my Single page HTML5 web application, I have encountered a scrolling issue. To scroll to the top of the page, I am implementing the following code: $('html, body').animate({ scrollTop: 0 }, 800); This functionality works ...

How can jQuery verify if an input value is contained within an array?

I've been attempting to verify if the value of an input field is part of an array, but for some reason it's not working. Here is my approach: var postcode1 = []; for (var i = 21000; i < 21999; i++) { postcode1.push({ val: i, text ...

Fix the positioning of a div in BootStrap and CSS code

Hey there, I'm relatively new to CSS/Bootstrap and currently in the process of learning. I might need to incorporate some CSS into the "chat_funcs" div, but unsure about what code to input to achieve my desired outcome. The issue at hand: What I am ...

Issues with Joomla's mobile menu compatibility

We are currently working on a Joomla website that can be accessed through this link. The site functions perfectly with two menus when viewed on a desktop screen. However, the issue arises when it is accessed from a smartphone like an iPhone 5, as instead o ...

Can you guide me on how to adjust the correct view on my controller?

After successfully inserting data using jQuery AJAX within a modal, I am encountering a problem where the view appears differently than expected. Below is a snippet of my AjaxCrudController: public function store(Request $request) { // $create = ...

How can you alter the background color of a Material UI select component when it is selected?

I am attempting to modify the background color of a select element from material ui when it is selected. To help illustrate, I have provided an image that displays how it looks when not selected and selected: Select Currently, there is a large gray backgr ...