Displaying additional slides on Bootstrap 4's fully responsive carousel

I am currently using Bootstrap 4 carousel and attempting to make it full width. It appears to be full width initially, but upon viewing it on larger screens, the subsequent sliders after the first one are displayed as well. You can try zooming out the window to see the issue.

Is there a way to rectify this problem?

Below is my code snippet:

.first-slide {
  background: url("https://image.ibb.co/kvhXGH/jetty_1373173_1920.jpg");
}

.carousel-item {
  height: 800px;
  width: 100%;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>

  <div class="container-fluid p-0">
    <div id="carouselExampleControls" class="carousel slide" data-ride="carousel" data-interval="false">
      <div class="carousel-inner" role="listbox">
        <div class="carousel-item active first-slide">
          <div class="row">
            <div class="col-md-6 offset-md-1">
              <h1>Title</h1>
              <p>Text goes here</p>
            </div>
            <div class="col-md-5"></div>
          </div>
        </div>
        <div class="carousel-item first-slide">
          <div class="row">
            <div class="col-md-6 offset-md-1">
              <h1>Title</h1>
              <p>Text goes here</p>
            </div>
            <div class="col-md-5"></div>
          </div>
        </div>
        <div class="carousel-item first-slide">
          <div class="row">
            <div class="col-md-6 offset-md-1">
              <h1>Title</h1>
              <p>Text goeshere</p>
            </div>
            <div class="col-md-5"></div>
          </div>
        </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>
    </div>

  </div>

Answer №1

Did you think about examining the code on Bootstrap's official website?

.carousel-item img {
  max-height: 100vh; 
  object-fit: cover;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>

<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img class="d-block w-100" src="https://image.ibb.co/kvhXGH/jetty_1373173_1920.jpg" alt="First slide">
      <div class="carousel-caption d-none d-md-block">
        <h5>Title</h5>
        <p>Text goes here</p>
      </div>
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="https://image.ibb.co/kvhXGH/jetty_1373173_1920.jpg" alt="Second slide">
      <div class="carousel-caption d-none d-md-block">
        <h5>Title</h5>
        <p>Text goes here</p>
      </div>
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="https://image.ibb.co/kvhXGH/jetty_1373173_1920.jpg" alt="Third slide">
      <div class="carousel-caption d-none d-md-block">
        <h5>Title</h5>
        <p>Text goes here</p>
      </div>
    </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>

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

What steps do I need to take to create my own Japanese tatami mat design?

Looking to design an HTML layout inspired by the classic Japanese tatami mat pattern. https://i.sstatic.net/vLUtp.png Experimented with using rowspan and colspan in a table layout, making progress until the final colspan caused things to collapse. td ...

What is the best way to align various types of content within a div container

I'm struggling with aligning a label next to a checkbox in my HTML code using Vue.js. Here's how it looks: <div style="margin-bottom: 15px;"> <input id="newsletterRegister" type="checkbo ...

Using CSS to encompass a group of words within a circular shape

I am attempting to encircle multiple words within one circle, but currently each word is enclosed in its own circle. Below is the code I am currently using. HTML <div class="numberCircle"> <span>Circle all words</span> </div> ...

How to retrieve the width of an unspecified element using JavaScript

Seeking help with a div element that adjusts its size based on the elements it contains. How can I determine the final size of this dynamic div without checking the sizes of its internal elements? I've attempted to parse all the properties of the obj ...

The Ionic framework modal is displaying a mysterious black dropdown, devoid of any content

I am currently working on an ionic hybrid app and encountering an issue with the modal functionality. Upon invoking the modal.show() method, I can see the black overlay but not the actual content of the modal (I have copied the example from the documentat ...

Issues arise with HTML and CSS when users begin to scroll the page

Could really use some assistance here! I created this website for a friend, but the color of the menu bar mysteriously disappears when I scroll to the right. Any suggestions or ideas on how to fix this issue would be greatly appreciated. The site in quest ...

Creating a div that takes up 100% of its parent's height, regardless of the children's dimensions, in a sophisticated layout

My webpage layout is structured as follows: https://i.sstatic.net/5rdiw.png The left side, identified as D, functions perfectly. It contains a significant amount of content that scrolls correctly. Even as the content increases, the height stays at 100% o ...

How to easily align an image and blockquote vertically in CSS with automatic width for the blockquote

I am struggling with a layout issue involving a list of items containing images and blockquotes. My goal is to set a maximum width for the images and have the blockquotes automatically adjust their size to fit next to the images, all while keeping both ele ...

Unable to click on hyperlink and image not adjusting in size

I am having an issue with the anchor tags inside a div. For some reason, the width and height are set to 0px, and I have tried to adjust them with no success. Each dot in my onepage scroller is meant to navigate to a different page. .dotstyle-scaleup{ f ...

What is the best method for serving static files within a nested EJS view directory?

Assuming I have the directory structure below: |--Views/ | --partial/ | --links.ejs | |--assets/ | --css/ | --styles.css | |--server.js Code for links.ejs <link rel="stylesheet" type="text/css" href="css/forms/switches.css"& ...

How can I convert the left links in my navigation bar to a CSS drop-down menu to make it more responsive on small screens?

Here is the structure of my HTML (at the top): <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></s ...

Tips for refreshing the <img> tag using a user image

I am currently designing a bootstrap webpage and trying to implement a feature where the user can input an image, which will then be displayed in a preview modal along with some text provided by the user. The modal is functioning correctly. Here is the co ...

Add a new row to the table when a dropdown option is selected, and remove the row when deleted. Ensure that the row is only added

Here is my specific requirement: I need a table with a default row containing a dropdown menu in the first column. When an option is selected from the dropdown, a new table row should be added with the same content as the main row and a delete button for ...

What is the best way to create space between two flex elements that doesn't follow a

Dealing with a challenge in Flexbox. I am trying to establish a specific distance between two flexible elements. I understand that I should use justify-content, but unfortunately cannot set an exact distance using it. Avoiding the use of margins or othe ...

When a page is being redirected using requestdispatcher in a filter, the CSS contents do not seem to be applying correctly

Upon evaluation of the condition, if it fails, I am utilizing a request dispatcher to redirect to another page. The redirection is successful, however, the CSS is not being applied to the new page. What could be causing this issue? public class RolePrivil ...

I can't figure out what's not working with my full-width video cover

I'm having trouble creating a full-width video cover for the header of a website. Can someone help me troubleshoot what I'm doing wrong? Here is a snippet of my code: <section id="home"> <video poster="assets/img/home-bg.png" a ...

Make a portion of the title come alive on hover

Looking to add animation to a title that consists of two parts: "HARD" and "WARE", with the second part having a more transparent color. When hovering over the "HARD" word, the colors reverse correctly. However, when hovering over the "WARE" word, only on ...

Is it feasible to place an image on top of a box?

Hello everyone, I have been trying to figure out how to achieve a specific layout in React. I am using MUI so there is no need for any hard-coded CSS. However, my attempts have not been successful so far. The layout I am aiming for consists of an image on ...

Facing issues with displaying CSS and images on Django website

Just starting out with Django and encountering some trouble getting my CSS and images to display in my home.html file. I attempted to add a STATICFILES_DIR based on some research I did, but the content still isn't showing up. I also experimented with ...

When it comes to creating a CSS drop-down menu, don't forget to incorporate an additional <ul

I've created a drop-down menu using CSS with 5 visible list items. When hovering over one of the list items, it highlights and triggers a drop-down effect to display another list underneath. Essentially, you have an initial set of options, and upon ho ...