Issue with auto-sliding feature on Bootstrap carousel

Wishing you a wonderful day! I'm encountering an issue where only the first slide appears for a few seconds before disappearing completely. Strangely, if I use the side arrows or buttons before the slide disappears, it functions normally.

HTML

<header>
    <div class="row row-content">
        <div class="col">
            <div id="mycarousel" class="carousel slide" data-ride="carousel">
                <div class="carousel-inner" role="listbox">
                    
                    <div class="carousel-item active">
                        <img src="img/img1.png" class="d-block img-fluid">
                        <div class="carousel-caption d-none d-md-block" alt="img1">
                            <h2>text</h2>
                            <p class="d-none d-sm-block">text</p>
                        </div>
                    </div>

                    <div class="carousel-item">
                        <img src="img/img2.png" class="d-block img-fluid">
                        <div class="carousel-caption d-none d-md-block" alt="img2">
                            <h2>text</h2>
                            <p class="d-none d-sm-block">text</p>
                        </div>
                    </div>

                    <div class="carousel-item">
                        <img src="img/img3.png" class="d-block img-fluid">
                        <div class="carousel-caption d-none d-md-block" alt="img3">
                            <h2>text</h2>
                            <p class="d-none d-sm-block">text</p>
                        </div>
                    </div>
                   
                    
                </div>
                <ol class="carousel-indicators">
                    <li data-target="#mycarousel"data-slide-to="0" class="active"></li>
                    <li data-target="#mycarousel"data-slide-to="1" class="active"></li>
                    <li data-target="#mycarousel"data-slide-to="2" class="active"></li>
                </ol>
                <a  class="carousel-control-prev" href="#mycarousel" role="button" data-slide="prev">
                    <span class="carousel-control-prev-icon"></span>
                </a>
                <a  class="carousel-control-next" href="#mycarousel" role="button" data-slide="next">
                    <span class="carousel-control-next-icon"></span>
                </a>
            </div>
        </div>
    </div>
</header>

CSS

.carousel-item {
  height: 420px;
}
.carousel-item img {
  position: absolute;
  top: 0;
  left: 0;
  min-height: 420px;
}

Answer №1

Everything looks great with this example I created - it's working perfectly! Make sure you have added the necessary JS library because your code seems to be correct.

.carousel-item {
  height: 420px;
}
.carousel-item img {
  position: absolute;
  top: 0;
  left: 0;
  min-height: 420px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>

    <header>
            <div class="row row-content">
                <div class="col">
                    <div id="mycarousel" class="carousel slide" data-ride="carousel">
                        <div class="carousel-inner" role="listbox<
                            
                            <div class="carousel-item active">
                                <img src="https://www.lupadigital.info/wp-content/uploads/2018/05/imagens-gratis.jpg" class="d-block img-fluid">
                                <div class="carousel-caption d-none d-md-block" alt="img1">
                                    <h2>text</h2>
                                    <p class="d-none d-sm-block">text</p>
                                </div>
                            </div>

                            <div class="carousel-item">
                                <img src="https://www.lupadigital.info/wp-content/uploads/2018/05/imagens-gratis.jpg" class="d-block img-fluid">
                                <div class="carousel-caption d-none d-md-block" alt="img2">
                                    <h2>text</h2>
                                    <p class="d-none d-sm-block">text</p>
                                </div>
                            </div>

                            <div class="carousel-item">
                                <img src="https://www.lupadigital.info/wp-content/uploads/2018/05/imagens-gratis.jpg" class="d-block img-fluid">
                                <div class="carousel-caption d-none d-md-block" alt="img3">
                                    <h2>text</h2>
                                    <p class="d-none d-sm-block">text</p>
                                </div>
                            </div>
                           
                            
                        </div>
                        <ol class="carousel-indicators">
                            <li data-target="#mycarousel"data-slide-to="0" class="active"></li>
                            <li data-target="#mycarousel"data-slide-to="1" class=""></li>
                            <li data-target="#mycarousel"data-slide-to="2" class=""></li>
                        </ol>
                        <a  class="carousel-control-prev" href="#mycarousel" role="button" data-slide="prev">
                            <span class="carousel-control-prev-icon"></span>
                        </a>
                        <a  class="carousel-control-next" href="#mycarousel" role="button" data-slide="next">
                            <span class="carousel-control-next-icon"></span>
                        </a>
                    </div>
                </div>
            </div>
        </header>
        
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>

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

Is it possible to modify the :hover effects of a material-ui outlined select component?

I am currently developing a react application using Material UI. My goal is to change the color of a selector to white when hovering over it. However, I have encountered difficulties in applying the style as intended. Even when directly adding classes, the ...

What is the best way to calculate the total of multiple columns using JavaScript and jQuery?

I am looking to modify my table that has two different columns in order to calculate the sum of both. Currently, I can only add up one column using JavaScript, and duplicating the JS code with different value names for the second column is not ideal. How c ...

Creating a Dynamic Slideshow Rotation

Seeking help with an HTML5/jQuery slideshow system... I need the images to rotate continuously without pausing. Currently, when I reach the last slide, it goes back to the first by changing the margin-left to 0. Ideally, I want it to loop indefinitely. A ...

The output of new Date() varies between app.js and ejs

app.get("/test",function(req,res){ var d = new Date(); res.send(d); }); When I access mydomain/test, it displays the output "2019-03-19T04:50:47.710Z" which is in UTC. app.get("/testejs",function(req,res){ res.render("testejs");}); Below is the content ...

Combining two Unix timestamps into a single value

Looking for a way to condense a date range into GET parameters for my application, I pondered the possibility of encoding two Unix timestamps into a single parameter to minimize URL length. While a basic CSV of two timestamps would suffice, my aim is to f ...

Choosing the Standard Option from the Drop-Down Menu

Is there a way to set a default value in the drop-down menu below? <div hidden id="projectSelected"> <label style="font-size: medium">Project *</label> <select name="projectSelected" id="projectSelectedId" class="form-control" ...

Retrieve all radio inputs within dynamically generated divs

Each dynamically generated div contains 4 radio buttons: $(".wrapper").on("custom", ".item", function(){ $.each($(".item"),function(){ // Get all radio names and check if at least one is checked var radio_groups = []; ...

Guide to assigning an integer value to a string in Angular

Is there a way to change integer values in a table to actual names and display them on a webpage by setting a scope in the controller and passing that string to the HTML? For example, this is an example of the HTML code for the table row: <thead> ...

Validation can only be performed one tab at a time

I have utilized BootstrapWizard to create a wizard, but I am in need of validating the input before proceeding to save them. Currently, when I complete the first tab, I am unable to move on to the next tab because the valid() method returns false. The val ...

.gltf file failing to load in the web browser

I am facing an issue with a .gltf file. While I can open it with a 3D viewer, I encounter difficulties when trying to load it in the browser. The file loads without any errors in the console, but it fails to show up in the scene. Even attempts to load the ...

Creating a drop-down menu in HTML with PHP and MySQL integration

I'm currently working on populating a list into a drop-down menu, but right now it's displaying each name in its own separate drop-down. I'd like to have all the names listed in just one single drop-down instead. Any ideas on how I could ach ...

Ways to obtain the <a> using the title attribute

Is there a way to remove 3 classes from a specific <a> element that is dynamically generated? The only constant is the title. How can I locate an element based on its title? I've searched online but haven't found exactly what I'm looki ...

Expanding and filling the parent container both horizontally and vertically with Bootstrap 4 cards arranged in columns

Utilizing Bootstrap 4, I have constructed a row with 3 columns, each set to a size of 4 on medium and larger displays. Although the content within these cards may vary in size, my goal is to ensure that each card maintains an equal length. I have opted ag ...

Finding parent elements using parentElementArrayFinder

Is there a specific attribute called parentElementArrayFinder within an ElementFinder object that can retrieve the parent element? var myElement = $(".myclass"); var parentElement = myElement.parentElementArrayFinder; Although not listed in Protractor&ap ...

Tips on getting your card to stay at the top

Screenshot of webpage HTML (EJS): In the HTML file, look for the section after <%- include("navbar.ejs") -%> inside the body tag. The ".cardholder" contains "anime-card" templates (card.ejs). The first and last div within ".cardholder" are ...

How can I ensure a DIV is shown on every sub-page?

Is there a way to dynamically display a <div id="chatbox"> in all subpages without needing to manually edit each one? For example, adding this code to the main index.html file and having it appear on /products/index.html. ...

Creating an NPM Module: Importing your own package as a dependency

Currently, I am in the process of developing a new NPM package. The repository includes an examples directory containing some JavaScript code that is compiled and served locally (or potentially through github.io). The configuration is reminiscent of the s ...

Stacking items when clicked on with jQuery UI Draggable

Can a draggable's stack procedure be activated by clicking instead of just dragging? I came across this solution, which essentially replicates the library code (with an important addition I included below). Is there a more elegant approach to achieve ...

Need a stylish Noun Project CSS container?

I've looked everywhere for the link, including scouring through Hacker News where I first saw the project, but haven't had any success. Instead of downloading images from The Noun Project and similar sources, is there a way to simply include a C ...

Choose a selection from a dropdown to automatically update the value in a text box

I'm currently developing a form that includes both drop-down menus and text boxes. I need the value selected in one drop-down to dynamically change the value in the corresponding text box. For example, if I choose "3" from the drop-down menu, it shou ...