Bootstrap version 4 introduces a feature-packed carousel with thumbnail navigation, perfect

I recently came across a carousel demo with thumbnails using bootstrap 3 which you can view here.

I attempted to replicate this using bootstrap v4, but encountered difficulties with the left/right shadows overlapping the thumbnails. You can see my attempt with v4 here.

Below is the HTML code:

<div id='carousel-custom' class='carousel slide' data-ride='carousel'>
    <!-- Wrapper for slides -->
    <div class='carousel-inner'>
        <div class='carousel-item active'>
            <img src='http://placehold.it/400x200&text=slide1' alt='' />
        </div>
        <div class='carousel-item'>
            <img src='http://placehold.it/400x200&text=slide2' alt='' />
        </div>
        <div class='carousel-item'>
            <img src='http://placehold.it/400x200&text=slide3' alt='' />
        </div>
    </div>

    <!-- Controls -->
    <a class='left carousel-control' href='#carousel-custom' data-slide='prev'>
        <span class='glyphicon glyphicon-chevron-left'></span>
    </a>
    <a class='right carousel-control' href='#carousel-custom' data-slide='next'>
        <span class='glyphicon glyphicon-chevron-right'></span>
    </a>

    <!-- Indicators -->
    <ol class='carousel-indicators'>
        <li data-target='#carousel-custom' data-slide-to='0' class='active'><img
                src='http://placehold.it/100x50&text=slide1' alt='' /></li>
        <li data-target='#carousel-custom' data-slide-to='1'><img src='http://placehold.it/100x50&text=slide2' alt='' />
        </li>
        <li data-target='#carousel-custom' data-slide-to='2'><img src='http://placehold.it/100x50&text=slide3' alt='' />
        </li>
    </ol>
</div>

For CSS Changes:

#carousel-example-generic {
    margin: 20px auto;
    width: 400px;
}

#carousel-custom {
    margin: 20px auto;
    width: 400px;
}
#carousel-custom .carousel-indicators {
    margin: 10px 0 0;
    overflow: auto;
    position: static;
    text-align: left;
    white-space: nowrap;
    width: 100%;
}
#carousel-custom .carousel-indicators li {
    background-color: transparent;
    -webkit-border-radius: 0;
    border-radius: 0;
    display: inline-block;
    height: auto;
    margin: 0 !important;
    width: auto;
}
#carousel-custom .carousel-indicators li img {
    display: block;
    opacity: 0.5;
}
#carousel-custom .carousel-indicators li.active img {
    opacity: 1;
}
#carousel-custom .carousel-indicators li:hover img {
    opacity: 0.75;
}

Answer №1

Incorporating Bootstrap 4 into your design can simplify the process by utilizing the list-inline class for slider thumbnails, reducing the need for additional CSS customization.

<div class="col-lg-6 offset-lg-3" id="slider">
  <div id="myCarousel" class="carousel slide">
    <div class="carousel-inner">
      <div class="active item carousel-item" data-slide-number="0">
        <img src="http://placehold.it/1200x480&amp;text=one" class="img-fluid">
      </div>
      <div class="item carousel-item" data-slide-number="1">
        <img src="http://placehold.it/1200x480/888/FFF" class="img-fluid">
      </div>
      <div class="item carousel-item" data-slide-number="2">
        <img src="http://placehold.it/1200x480&amp;text=three" class="img-fluid">
      </div>
      <div class="item carousel-item" data-slide-number="3">
        <img src="http://placehold.it/1200x480&amp;text=four" class="img-fluid">
      </div>
      <div class="item carousel-item" data-slide-number="4">
        <img src="http://placehold.it/1200x480&amp;text=five" class="img-fluid">
      </div>
      <div class="item carousel-item" data-slide-number="5">
        <img src="http://placehold.it/1200x480&amp;text=six" class="img-fluid">
      </div>
      <div class="item carousel-item" data-slide-number="6">
        <img src="http://placehold.it/1200x480&amp;text=seven" class="img-fluid">
      </div>
      <div class="item carousel-item" data-slide-number="7">
        <img src="http://placehold.it/1200x480&amp;text=eight" class="img-fluid">
      </div>
      
      <a class="carousel-control left pt-3" href="#myCarousel" data-slide="prev"><i class="fa fa-chevron-left"></i></a>
      <a class="carousel-control right pt-3" href="#myCarousel" data-slide="next"><i class="fa fa-chevron-right"></i></a>
      
    </div>
    
    
    <ul class="carousel-indicators list-inline">
      <li class="list-inline-item active">
        <a id="carousel-selector-0" class="selected" data-slide-to="0" data-target="#myCarousel">
          <img src="http://placehold.it/80x60&amp;text=one" class="img-fluid">
        </a>
      </li>
      <li class="list-inline-item">
        <a id="carousel-selector-1" data-slide-to="1" data-target="#myCarousel">
          <img src="http://placehold.it/80x60&amp;text=two" class="img-fluid">
        </a>
      </li>
      <li class="list-inline-item">
        <a id="carousel-selector-2" data-slide-to="2" data-target="#myCarousel">
          <img src="http://placehold.it/80x60&amp;text=three" class="img-fluid">
        </a>
      </li>
      <li class="list-inline-item">
        <a id="carousel-selector-3" data-slide-to="3" data-target="#myCarousel">
          <img src="http://placehold.it/80x60&amp;text=four" class="img-fluid">
        </a>
      </li>
      <li class="list-inline-item">
        <a id="carousel-selector-4" data-slide-to="4" data-target="#myCarousel">
          <img src="http://placehold.it/80x60&amp;text=five" class="img-fluid">
        </a>
      </li>
      <li class="list-inline-item">
        <a id="carousel-selector-5" data-slide-to="5" data-target="#myCarousel">
          <img src="http://placehold.it/80x60&amp;text=six" class="img-fluid">
        </a>
      </li>
      <li class="list-inline-item">
        <a id="carousel-selector-6" data-slide-to="6" data-target="#myCarousel">
          <img src="http://placehold.it/80x60&amp;text=seven" class="img-fluid">
        </a>
      </li>
      <li class="list-inline-item">
        <a id="carousel-selector-7" data-slide-to="7" data-target="#myCarousel">
          <img src="http://placehold.it/80x60&amp;text=eight" class="img-fluid">
        </a>
      </li>
    </ul>
  </div>
</div>

Answer №2

When you relocate your controls within the .carousel-inner element, they will no longer extend downwards past the thumbnails:

<div class='carousel-inner'>
    <div class='carousel-item active'>
        <img src='http://placehold.it/400x200&text=slide1' alt='' />
    </div>
    <div class='carousel-item'>
        <img src='http://placehold.it/400x200&text=slide2' alt='' />
    </div>
    <div class='carousel-item'>
        <img src='http://placehold.it/400x200&text=slide3' alt='' />
    </div>

    <div class='carousel-item'>
        <img src='http://placehold.it/400x200&text=slide4' alt='' />
    </div>
    <div class='carousel-item'>
        <img src='http://placehold.it/400x200&text=slide5' alt='' />
    </div>
    <div class='carousel-item'>
        <img src='http://placehold.it/400x200&text=slide6' alt='' />
    </div>

    <div class='carousel-item'>
        <img src='http://placehold.it/400x200&text=slide7' alt='' />
    </div>
    <div class='carousel-item'>
        <img src='http://placehold.it/400x200&text=slide8' alt='' />
    </div>
    <div class='carousel-item'>
        <img src='http://placehold.it/400x200&text=slide9' alt='' />
    </div>

    <!-- Controls -->
    <a class='left carousel-control' href='#carousel-custom' data-slide='prev'>
      <span class='glyphicon glyphicon-chevron-left'></span>
    </a>
    <a class='right carousel-control' href='#carousel-custom' data-slide='next'>
      <span class='glyphicon glyphicon-chevron-right'></span>
    </a>

</div>

Check out the updated fiddle for reference: JSFiddle

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

Can we find a solution to optimize "Crystal Reports" for mobile browsers and make it responsive?

I'm in the process of making my entire Asp.net application responsive for mobile browsers by utilizing Bootstrap. However, I've encountered a challenge with making Crystal Report responsive for mobile browsers. If anyone has any advice on how to ...

"Track the progress of a form submission with a loading indicator using Sweet

I am looking to incorporate a waiting time animation when submitting a form, and I prefer using SweetAlert over a traditional loading image. Here is the basic code snippet: $("form").submit(function (e) { e.preventDefault(); // prevents def ...

Tips for extracting specific values from JavaScript using jQuery in ASP to be utilized in the C# code behind section

I want to extract the selected values from a multiselect jQuery and use them in the code behind in C#. The script sources can be found at the following link: https://github.com/nobleclem/jQuery-MultiSelect Below is the ASP code I am using: <div class ...

Angular 2: Dealing with Missing Image Loading

When viewing an HTML file containing the following code: <div> <img src="New-Google-Logo.png"/> </div> The image file New-Google-Logo.png is expected to load from the same folder as the HTML file. However, after running ng s ...

Having trouble viewing the initial value in an AngularJS2 inputText field

I'm having trouble displaying the initial value in inputText. I'm unsure of what mistake I'm making, but the value should be showing up as expected. Kind regards, Alper <input type="text" value="1" [(ngModel)]="Input.VSAT_input1" name= ...

Utilize Javascript to extract and showcase JSON data fetched from a RESTful API

I'm attempting to use JavaScript to pull JSON data from a REST API and display it on a webpage. The REST call is functioning correctly in the Firefox console. function gethosts() { var xhttp = new XMLHttpRequest(); xhttp.open("GET", "https://10 ...

Highlighted text with CSS

For this exercise, I was provided with the following HTML code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Selected text</title> </head> <body> <div class ...

Application of Customized Bootstrap CSS Not Successful

I have noticed that my custom CSS file does not override the bootstrap.min.css unless I include the !important tag in the class. Specifically, when I try to change the color of my background header. .bg-grey{ background-color:#333 !important; } The ...

The use of JQuery's .show() and .hide() functions may disrupt the functionality of CSS hover

When working with this jsFiddle, it appears that the jQuery .show() function does not behave as expected. Despite the documentation stating that it should revert CSS attributes to their original values, using .show(x).delay(x).hide(x) seems to cause the CS ...

Creating dynamic DIVs that adjust fluidly to different screen

I have a section containing 4 centered divs. Here is what I want to achieve: When the screen width is over 1280px, display all 4 divs in a row. When the screen width is less than 1280px, show 2 divs per row. And when the screen width is under 640px, disp ...

Rendering HTML strings instead of HTML in ReactJS

When I try to display HTML, all I see is strings var ref = firebase.database().ref('raffle/'); ref.on('value', (snapshot) => { var content = ``; var IDwrapper = document.getElementById('raffleFeed'); snapshot.forEac ...

Excessive whitespace appearing on the right and bottom edges of the Angular application

I'm fairly new to web development, so this may be a silly question, but I really could use some help. I've created my first Angular app and noticed that there is a lot of white space on the right side of the landing page, as well as at the bottom ...

Populate the textbox with data from the database when the dropdown selection changes

I am looking to automatically populate the text box with a value from the database when a selection is made from a drop-down list using php When an option is chosen from the drop-down list, the text box should display a corresponding record based on the s ...

What methods are available to modify HTML content using Node.js?

I am looking to modify the contents of my HTML file (index.html) below: <html> <body> <div id="greeting">Hello world</div> </body> </html> I want to change this using Node.js in the backend. Below is the Node.js cod ...

What is the best way to locate and list all video links, and include options for "Play Video" and "Download Video"?

I have a project where I am using PHP to crawl and generate video links from the web. Now, I am looking to implement an option for users to either "Play Video" or "Download Video" when a video link is detected, along with adding a video player if the user ...

Is there a way to verify if text was generated using CSS?

I am working with the following HTML structure: <h4 id="myModalLabel"></h4> In my CSS, I have set the content dynamically using the following code: #myModalLabel::after { content: "gebeurtenis"; } For a live example, you can check out t ...

I'm curious why I can only see the HTML code and not the three.js code as well

I attempted to run a sample three.js game today, but only the HTML code appeared. I've also installed three.js with npm and tried running it with the VSC Live Server, but it's not working. You can find the source code here. What should be my nex ...

Dynamically insert innerHTML content into table rows using JavaScript in PHP is a fantastic way to customize

Having trouble with innerHTML in this scenario, looking to achieve something along these lines: <table width="100%" border="0" id="table2"> <?php include("connection.php"); $sql=mysql_query("select* from b1"); while($res=mys ...

Arrange and overlay PNG images within a Bootstrap container using position:absolute

I've been attempting to align and stack some images within a bootstrap grid, but I'm having some trouble. Instead of aligning within the grid, the images seem to align to the window instead. I've been using position:absolute, which I found ...

In iOS devices, the Ionic framework restricts the ability to open links in a new tab using the ng-href attribute

In my quest for mobile functionality, I'm aiming to implement a feature on devices where tapping will open 'codepen.io' (triggered by ng-click), and tap and hold will display a context menu with the option to 'Open In New Tab', red ...