The carousel in Bootstrap v4 seems to vanish after the initial slide :/

(Please note that I am a student and still learning, so gentlemen, please don't be upset with the question. Thank you.)

In short:

I have integrated the Bootstrap v4 carousel (https://getbootstrap.com/docs/4.0/components/carousel/) into the header of my website and it works great, but the carousel disappears after the first slide.

I tried removing the container class, thinking it might conflict with the carousel position, but it didn't help.

(I searched on Bootstrap, on Stack Overflow, nothing :( )

Designers, could you please assist me?

Thank you in advance.

P.S. The images are of the same size.

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

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=noS">
 <title>Home</title>

 <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet"gt;;
  
 <!-- Custom styles for this template -->
 <link href="css/business-frontpage.css" rel="stylesheet";>
 <!-- Latest compiled and minified CSS -->
 <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
 <script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
 <link rel="preconnect" href="https://fonts.gstatic.com">;
 <l챕nk href="https://fonts.googleapis.com/css2?family=Italianno&display=swap" rel="stylesheet";>; 
</head>;

<body>;
  <<!-- Navigation -->>;
  <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">;
    <div class="container">;
      <a class="navbar-brand" href="#">Welcome  </a>;
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">;
        <span class="navbar-toggler-icon"></span>;
      </button>;
      <div class="collapse navbar-collapse" id="navbarResponsive">;
        <ul class="navbar-nav ml-auto">;
          <li class="nav-item active">;
            <a class="nav-link" href="#">Home
              <span class="sr-only">(current)</span>;
            </a>;
          </li>;
          <li class="nav-item">;
            <a class="nav-link" href="#">Text</a>;
          </li>;
          <li class="nav-item">;
            <a class="nav-link" href="#">Text</a>;
          </li>;
          <li class="nav-item">;
            <a class="nav-link" href="#">Service</a>;
          </li>;
          <li class="nav-item">;
            <a class="nav-link" href="#">Text</a>;
          </li>;
          <li class="nav-item">;
            <a class="nav-link" href="#">Text</a>;
          </li>;
          <li class="nav-item">;
            <a class="nav-link" href="#">Text</a>;
          </li>;
          <li class="nav-item">;
            <a class="nav-link" href="#">Contact</a>;
          </li>;   
        </ul>;
      </div>;
    </div>;
    <form class="form-inline my-2 my-lg-0">;
            <a class="nav-link" href="#">ENG</a>;
            <a class="nav-link" href="#">GER</a>;
            <a class="nav-link" href="#">FR</a>;
    </form>;  
</nav>;
   
<!-- Header -->>;
<!-- carousel -->>;
  <header class="bg-primary bg-dark py-3 mb-5">;
    <div class="container h-100">   ;;
     <div id="carousel" class="carousel slide" data-ride="carousel">;
     <ol class="carousel-indicators"> ;
          <li data-target="#carousel" data-slide-to="0" class="active"></li>;
          <li data-target="#carousel" data-slide-to="1"></li>;
     </ol>;
         
     <div class="carousel-inner">;
        <div class="carousel-item active">;
            <img src="1.jpg"  class="img-fluid">;
            <div class="carousel-item">;
            <img src="11.jpg" class="img-fluid">;
          </div>;
        </div>;

        <a class="left carousel-control" href="carousel" data-slide="prev">;
          <span class="glyphicon glyphicon-chevron-left"></span></a><a class="right carousel-control" href="#carousel-example-generic" data-slide="next"><span class="glyphicon glyphicon-chevron-right">
        </span></a>;
      </div>;
      
      <div class="main-text hidden-xs">;
        <div class="col-md-12">;
            <p class="h1"><span><b>text</b></span></p><h1 class="text-white"><span><b>&nbsp &nbsp &nbsp text</b></span></h1></b>;
        </div>;
      </div>;
        </header>;
<!-- carousel -->>;;
>;

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

;

https://i.sstatic.net/1rWRA.png

;

Answer №1

The carousel code you have is tailored for Bootstrap 3, which utilizes glyphicons while Bootstrap 4 opts for SVGs. Without including the CSS or JS you are using, it's difficult to ascertain the versions of those elements in your setup.

To offer a solution, I integrated the Bootstrap 4 carousel with your navbar snippet to demonstrate its functionality. Since you have applied fixed-top to the navbar, you will need to add extra margin to the first section to ensure proper spacing below the navbar (I included an additional 4.5rem).

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9ffdf0f0ebecebedfeefdfabb1a9b1af">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d8bab7b7acabacaab9a898ecf6eef6e8">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>

<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
    <div class="container">
        <a class="navbar-brand" href="#">Welcome </a>
        <button class="navbar-toggler ml-auto" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarResponsive">
            <ul class="navbar-nav ml-auto">
                <li class="nav-item active">
                    <a class="nav-link" href="#">Home
                        <span class="sr-only">(current)</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">text</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">text</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">Service</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">text</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">text</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">text</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">Contact</a>
                </li>
            </ul>
        </div>
        <form class="form-inline my-2">
            <a class="nav-link px-2" href="#">ENG</a>
            <a class="nav-link px-2" href="#">GER</a>
            <a class="nav-link px-2" href="#">FR</a>
        </form>
    </div>
</nav>

<!-- Header -->
<!-- carousel -->
<header class="bg-primary bg-dark py-3 mb-5" style="margin-top: 4.5rem;">
    <div class=" container h-100">
        <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
            <ol class="carousel-indicators">
                <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
                <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
            </ol>
            <div class="carousel-inner">
                <div class="carousel-item active">
                    <img src="https://via.placeholder.com/1110x380.png/0000FF/FFFFFF?text=Slide+1" class="d-block w-100" alt="...">
                </div>
                <div class="carousel-item">
                    <img src="https://via.placeholder.com/1110x380.png/00FFFF/FFFFFF?text=Slide+2" class="d-block w-100" alt="...">
                </div>
            </div>
            <a class="carousel-control-prev" href="#carouselExampleIndicators" 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="#carouselExampleIndicators" role="button" data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="sr-only">Next</span>
            </a>
        </div>
        <div class="main-text hidden-xs">
            <div class="col-md-12">
                <p class="h1"><span><b>text</b></span></p>
                <h1 class="text-white"><span><b>&nbsp &nbsp &nbsp text</b></span></h1>
            </div>
        </div>
    </div>
</header>
<!-- carousel -->

It's highly recommended to utilize the snippet tool when posing queries involving web design.

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

Menu Drop on top of Flash player

A challenge I am currently facing is with my live event site and the list of events displayed in a mouseover menu. The issue arises when the flash streaming player remains in front of the mouseover menu, causing interference across all versions of Interne ...

Scraping a p tag lacking a class attribute with the help of BeautifulSoup4 (Bs4)

I am attempting to scrape this information from a website: enter image description here Within the HTML, there is a div tag with a class. Inside that div tag, there is another div tag and then a lone p tag without a class. My objective is specifically to ...

What causes the transformation from "&" to "&amp;" upon the completion of page loading?

While using Firefox and working on a page, I noticed that & turns into &amp;. Normally, I would fix this with html_entity_decode(), but it's not working in this case. Then I stumbled upon something interesting. An alert is triggered once the ...

Best way to eliminate empty options from dropdown and ensure that required validation is functioning in AngularJS?

My dropdown is populated with owners from the owners data, but it includes an extra blank option. I need to eliminate this blank option. However, when I make the necessary changes to remove it, the required validator stops working properly. <md-input-c ...

Tips for storing checkbox preferences in a user account on an HTML/PHP website

Hello! I am currently working on a website. I have included a checkbox that updates the option selected in phpMyAdmin. The issue I am facing is that when I press submit and then refresh the page using F5, the preference I chose disappears on the client s ...

The specified font is not loading despite being correctly defined

I have a font stored locally in resources/fonts/ and I'm correctly linking to it, but for some reason, it's not loading. Here is the <style> section in my html: <style> @font-face{ font-family:"franklin_gothic_condensed"; ...

Change the button's background color gradually when hovered over using CSS

Attempting to create a button that transitions its background color from blue to white and the font color from white to blue. I've reviewed similar posts for guidance. Here is the fiddle showcasing my work: http://jsfiddle.net/t533wbuy/1/ I used thi ...

There are certain table cells that have a white background color even though it was not explicitly set

While attempting to style an HTML table, I've encountered a strange issue. Despite not setting a background color for the table, some cells are appearing with a white background. Even after checking Firebug and confirming that no background color is s ...

Ways to create a gap between a model's label and the corresponding text field

I am attempting to create a gap between the label and text field using Twitter Bootstrap. Below is the screenshot https://i.sstatic.net/6f8CA.jpg I would like to add some space between User Name label area User Name text field same with other fields. I ...

Assess a nested variable using Thymeleaf syntax

My current task involves receiving bin data in JSON format. The number of bins in each section varies, like this example: var jsonmsg={"1": "SIXTY", "2": "DISCONNECTED", "3": "TWENTY", "4&quo ...

Universal HTML form validation with a preference for jQuery

Is there a jQuery plugin available for form validation that follows the most common rules? Specifically, I need to validate based on the following criteria: All textboxes must not be empty If the 'Show License' checkbox is checked, then the &a ...

Ways to dynamically eliminate focus around text inputs

I have created an HTML page and here is the link to it: https://i.sstatic.net/n8UdU.png My main goal is to remove the black border around the text input on this page. The challenge I am facing is that the 'things to do' list is generated dynamic ...

Encountering an error while utilizing ngForm in an HTML form

I have developed a custom component called "login", where I created an HTML form named "login.component.html". To convert this form into an Angular form, I added the code "" in login.component.html and imported import {NgForm} from '@angular/forms&apo ...

Ensure uniform height for all floating DIVS

Problem Description I'm facing an issue with the columns in my footer. I have a total of four columns, and I've applied the border-right property to all of them except for the last one: Due to varying content and height in each column, I am una ...

Tips on moving the inner rectangle within the outer rectangle

I am currently trying to center the innermost shape (the red shape) along the X-axis to the middle of the outermost shape (the black shape), while ensuring that the red shape remains within its direct parent, which is the blue shape. For instance, centeri ...

What is the best way to ensure that a Flex div and its child images stay confined within the boundaries of its parent container?

I'm struggling to create a responsive grid of images. I can't get the images to be both responsive with max-height and max-width, while also making sure the parent div takes up their full width. On the other hand, if I make the parent div the cor ...

Is the property in Angular not being initialized within the constructor?

Currently, I am implementing the Google Maps API in my latest project and encountered an undefined error within my code: export class AppComponent { startLocation: string; endLocation: string; maneuvers: any[]; constructor(private mapQuestService: ...

Tips for incorporating an anchor tag within an img tag in HTML?

Is it possible to add an anchor tag inside an img tag in HTML? <img src="img.jpg" alt="no img" /> I want to include the following inside the img tag: <a onclick="retake();" > Retake </a> The goal is to allow users to retake a photo by ...

Using HTML5 to play video from a stored binary string

I have been attempting to extract the data from a video file in binary format using the FileReader.readAsBinaryString(Blob|File) method, as demonstrated in this example http://www.html5rocks.com/en/tutorials/file/dndfiles/#toc-reading-files. My intention i ...

Utilizing Isotope JS on your Wordpress website

I'm in the process of integrating the .js plugin, Isotope, into my Wordpress installation. It should be positioned at the bottom of this page: To achieve this, I am referring to an example on codepen: https://codepen.io/desandro/pen/mEinp The script ...