Step-by-step guide on stacking multiple images in a Bootstrap 4 carousel

I'm struggling to figure out how to display multiple small images as thumbnails in a Bootstrap 4 carousel, instead of having them stretch to fill the width. I've attempted various solutions but can't seem to get the images to stack properly.

<div class="container">
    <h2 class="text-center">- Carousel -</h2><br>

    <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
        <div class="carousel-inner">
            <div class="carousel-item active">
                <img src="http://via.placeholder.com/250x250" alt="First slide">
            </div>
            <div class="carousel-item">
                <img src="http://via.placeholder.com/250x250" alt="Second slide">
            </div>
            <div class="carousel-item">
                <img src="http://via.placeholder.com/250x250" alt="Third slide">
            </div>
            <div class="carousel-item">
                <img src="http://via.placeholder.com/250x250" alt="Fourth slide">
            </div>
            <div class="carousel-item">
                <img src="http://via.placeholder.com/250x250" alt="Fifth slide">
            </div>
            <div class="carousel-item">
                <img src="http://via.placeholder.com/250x250" alt="Sixth slide">
            </div>
        </div>

        <a class="carousel-control-prev" href="#carouselExampleControls" 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="#carouselExampleControls" role="button" data-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"></span>
            <span class="sr-only">Next</span>
        </a>
    </div>
</div>

To see an example, check out the Highlights section on .

Answer ā„–1

The carousel slides can utilize the standard Bootstrap Grid system classes to achieve a similar effect as shown in this example. The following code demonstrates how five images are displayed in each slide, transitioning to the next block of five images as the carousel progresses.

<div id="gallery" class="carousel slide" data-ride="carousel">
    <div class="carousel-inner">
        <div class="carousel-item active">
            <div class="row">
                <div class="col">
                    <img class="img-fluid" src="http://via.placeholder.com/800x450/caa8f5/ffffff?text=Image+1" alt="Image 1"/>
                </div>

                <div class="col">
                    <img class="img-fluid" src="http://via.placeholder.com/800x450/9984d4/ffffff?text=Image+2" alt="Image 2"/>
                </div>

                <div class="col">
                    <img class="img-fluid" src="http://via.placeholder.com/800x450/592e83/ffffff?text=Image+3" alt="Image 3"/>
                </div>

                <div class="col">
                    <img class="img-fluid" src="http://via.placeholder.com/800x450/230c33/ffffff?text=Image+4" alt="Image 4"/>
                </div>

                <div class="col">
                    <img class="img-fluid" src="http://via.placeholder.com/800x450/b27c66/ffffff?text=Image+5" alt="Image 5"/>
                </div>
            </div>
        </div>

        <div class="carousel-item">
            <div class="row">
                <div class="col">
                    <img class="img-fluid" src="http://via.placeholder.com/800x450/f35b04/ffffff?text=Image+6" alt="Image 6"/>
                </div>

                <div class="col">
                    <img class="img-fluid" src="http://via.placeholder.com/800x450/f18701/ffffff?text=Image+7" alt="Image 7"/>
                </div>

                <div class="col">
                    <img class="img-fluid" src="http://via.placeholder.com/800x450/f7b801/ffffff?text=Image+8" alt="Image 8"/>
                </div>

                <div class="col">
                    <img class="img-fluid" src="http://via.placeholder.com/800x450/7678ed/ffffff?text=Image+9" alt="Image 9"/>
                </div>

                <div class="col">
                    <img class="img-fluid" src="http://via.placeholder.com/800x450/3d348b/ffffff?text=Image+10" alt="Image 10"/>
                </div>
            </div>
        </div>
    </div>

    <a class="carousel-control-prev" href="#gallery" 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="#gallery" role="button" data-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
    </a>
</div>


<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>

Answer ā„–2

Attempting to simulate a click event on the next button. Here's an example of how it can be done:

var timer = setInterval(function(){
    $('#nextButton').trigger('click');
 },2000)

Remember to reset the timer if the previous button is clicked. Failing to do so could result in unexpected behavior.

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

Dropping down with Twitter Bootstrap's navbar menu

Iā€™m currently facing some challenges with getting the Twitter Bootstrap drop-down navbar feature to function properly. Despite going through various tutorials, I am unable to make it work by directly copying the code. The console displays the following e ...

The button contains a clickable link inside it, however the button itself is not clickable

I am encountering an issue with a button that contains a link. Whenever I hover over the button, the cursor changes as expected, but clicking on the button itself does not trigger any action. Instead, I have to click on the link inside the button to redi ...

.ashx Handler malfunctioning when deployed on Server, functioning properly only when accessed locally

Executing this ajax request var request = $.ajax({ type: 'POST', url: "http://localhost/thcstore/AJAX/AjaxHawleySS.ashx", // url: "http://www.myrealsite.com/thcstore/AJAX/AjaxHawleySS.ashx", data: { Name: $('#Name').va ...

`Creating a functional list.js filter``

I'm having trouble making the List.js filter function work properly. The documentation for List.js is not very helpful for someone new to development. Below is the code I am using: HTML: <div class="col-sm-12" id="lessons"> <input class= ...

Can a piece of code be created that generates the XPath for a specific element?

I'm interested in finding out if there is a way to automatically generate an XPath by simply selecting an element, eliminating the need for manual updates when changes occur in HTML files on websites. I welcome any suggestions or alternatives that can ...

Concealing search components using JavaScript

I'm looking to hide elements that appear below the search field in the example code below. The code is sourced from W3: https://www.w3schools.com/howto/howto_js_filter_lists.asp. I only want the search elements to display when a user starts typing in ...

Tips for customizing elements using Wordpress

Is there a way to easily make my four divs containing icon images and descriptive text editable in WordPress? I have some experience setting up basics and using widgets in my footer and sidebar, but I'm not sure if that's the best approach for th ...

Mobile devices have a fixed distance and center alignment on the horizontal timeline

I am attempting to create a horizontal timeline similar to this example: https://codepen.io/ritz078/pen/LGRWjE The issue I am facing is that I do not have specific dates (DD/MM/YYYY) but only ranges such as 1998-2002 or single years like 2009. This has ca ...

How can I incorporate dynamic moving lines into my website's loading sequence?

Link to Gyazo image 1: https://gyazo.com/015425f0decb187e28b620c1e3206391 Issue with first image: https://gyazo.com/dfcd33e8a4fd5bea64e51fe40556f0bf I'm currently working on a website and came up with a cool concept of having two lines crossing the s ...

Incorporating the FLEX property into my code has been a challenge as it is not functioning properly on iOS 7 and 8 devices. Does anyone have any tips or suggestions on how to

While utilizing FLEX in my code, I noticed that the output is not what I expected on iOS 7/8 devices. <div className="modal-row"> <div className="col1"> <span>{dict.YourServiceNumber}</span> </div> <div ...

Ways to vertically align a div in Bootstrap 4?

As I delve into working with bootstrap 4, I am experimenting with creating various basic layouts. In line with the guidelines provided in bootstrap 4 documentation, I aimed to vertically align block elements by applying the class align-items-center. Despi ...

Animated div positioned on top of an image map

My current project can be found at: (please note that the sounds will not autoplay in the future). I am attempting to incorporate the sun effect from this codepen: https://codepen.io/Hackroro/pen/ByrKLZ I have realized that in order for the sun to appea ...

Implementing div elements in a carousel of images

I've been working on an image slider that halts scrolling when the mouse hovers over it. However, I'd like to use div tags instead of image tags to create custom shapes within the slider using CSS. Does anyone have any advice on how to achieve th ...

PHP returns the result of form submission to JavaScript, allowing for distinction between successful and unsuccessful outcomes

JavaScript: $("#register-form").submit(function(event) { event.preventDefault(); $.post("./register.php", { username: $("#username").val(), password: $("#password").val(), passwordtwo: $("#passwordtwo").val(), email: $ ...

Hide jQuery dropdown when mouse moves away

I am working on designing a navigation bar with dropdown functionality. Is there a way to hide the dropdown menu when the mouse pointer leaves both the navbar menu and the dropdown itself? I have tried using hover, mouseenter, and mouseleave but due to my ...

Switching from a top to bottom position can be quite the challenge for many

If there's a more efficient method for accomplishing what I'm about to inquire about, please inform me. So far, this is the best solution I could devise. I am looking to have a series of divs that enclose a sliding div within them. The sliding d ...

The entire image is unable to be shown within the div

When adding images to a carousel, I encountered an issue where only the top half of the image is displayed on the page. It seems that the image is not adjusting itself to fit the div container properly, resulting in only a portion of it being visible behin ...

What are the possible reasons for the failure of JavaScript when called dynamically through Ajax?

I've always been a big supporter of the JavaScript code for sorting tables. It's incredibly effective. However, I recently encountered an issue while trying to make the sorting function work with Ajax. I have a div layer on my main page that fe ...

What causes my child element to be positioned with respect to the body even though its parent is set to relative positioning?

Here is the HTML code I am working with: <html> <head></head> <body> <div id="board"> <div class="person"></div> </div> </body> </html> And here is the ...

Working with jQuery, CSS, and functions to modify the current tag's class

Let's keep it brief and straightforward: Here is my HTML <div id="headerVideoControls" class="overlayElement"> <div id="videoMuteUnmute" onclick="muteUnmuteVideo('headerVideo')">mute button</div> </div> Edited ...