The responsiveness of cards within the carousel-inner needs improvement

Despite successfully creating a carousel with 12 cards and 6 cards on each side, I am facing challenges with the responsiveness on mobile screens. I have tried numerous methods to make it responsive but have not achieved the desired results. The behavior of the carousel on mobile screens can be seen in this image: Carousel with cards. I have implemented my own carousel controls and I aim to utilize these controls for responsiveness. I also attempted to use the col-sm-2 feature without success.

.card-icon {
    position: absolute;
    top: 50%;
    right: -39px;
    transform: translateY(-50%);
  }
   .carousel-inner .active {
    display: block;
  }
  .carousel-inner-one{
    height: 200px;
  }
<div class="carousel-container">
                    <div id="carouselExampleControls" class="carousel carousel-dark slide" data-bs-ride="carousel">
                      <div class="carousel-inner-one">
                        <div class="carousel-item active">
                          <div class="row">
                            <div class="col-sm-1 col-md-6 my-4 d-flex">
                              <div class="card">
                                <div class="card-image">
                                  <img src="./assets/images/burger.jpg" class="card-img-top" alt="Card Image 1">
                                </div>
                                  <div class="card-body text-center">
                                    <h5 class="card-title">Buffalo Wings</h5>
                                  </div>   
                              </div>
                            </div>
                            <div class="col-lg-2 col-sm-1 col-md-6 my-4">
                              <div class="card">
                                <div class="card-image">
                                  <img src="./assets/images/burger.jpg" class="card-img-top" alt="Card Image 1">
                                </div>
                                  <div class="card-body text-center">
                                  <h5 class="card-title">Buffalo Wings</h5>
                                </div>
                              </div>
                            </div>
                            <div class="col-xl-2 col-sm-1 col-md-6 my-4">
                                ...
                                ...
                                ... (more card elements in similar structure)
                                ...
                                ...
                            </div>
 
                            <div class="icon">
                                ... (button for carousel control)
                            </div>    
                            <div class="card-icon">
                                ... (button for carousel control)
                            </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>

Answer №1

I successfully implemented the Bootstrap column classes, making the design responsive. I utilized placeholder images for testing purposes, which can easily be replaced with actual images.

  .card-icon {
  position: absolute;
  top: 50%;
  right: -39px;
  transform: translateY(-50%);
  /* updated code for hiding horizontal overflow */
  right: 0;      
}
.carousel-inner .active {
  display: block;
}
.carousel-inner-one{
  height: 200px;
}

/* updated code for hiding horizontal overflow */
.carousel-container{
  overflow: hidden;
}
<link rel="stylesheet" href="path/to/font-awesome/css/font-awesome.min.css">
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="82e0ededf6f1f6f0e3f2c2b7acb2acb0">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
  
<div class="carousel-container">
  <div id="carouselExampleControls" class="carousel carousel-dark slide" data-bs-ride="carousel">
    <div class="carousel-inner-one">
      <div class="carousel-item active">
        <div class="row">
          <div class="col-sm-12 col-md-6 col-lg-4 col-xl-2 my-4">
            <div class="card">
              <div class="card-image">
                <img src="https://picsum.photos/600/600?random=1" class="card-img-top" alt="Card Image 1">
              </div>
                <div class="card-body text-center">
                  <h5 class="card-title">Buffalo Wings</h5>
                </div>   
            </div>
          </div>
          
          <!-- More similar blocks follow with different random image links -->
          
        </div>
      </div>
        <div class="carousel-item">
          <div class="row">
            <div class="col-sm-12 col-md-6 col-lg-4 col-xl-2 my-4">
              <div class="card">
                <div class="card-image">
                  <img src="https://picsum.photos/600/600?random=7" class="card-img-top" alt="Card Image 1">
                </div>
                  <div class="card-body text-center">
                  <h5 class="card-title">Buffalo Wings</h5>
                </div>
              </div>
            </div>
            
            <!-- More similar blocks follow with different random image links -->
            
          </div>
        </div>
        <div class="icon">
          <button class="btn btn-primary button" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="prev"><i class="fas fa-chevron-left"></i></button>
        </div>    
        <div class="card-icon">
          <button class="btn btn-primary button" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="next">              
              <i class="fas fa-chevron-right"></i>            
          </button>
        </div>
  </div>
  </div>
</div>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="680a07071c1b1c1a0918285d4658465a">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></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

In a carousel slider, the height and width of divs are not set to specific dimensions

For a code snippet, you can visit this link: here The html: <html lang="en"> <head> <link href="https://fonts.googleapis.com/css?family=Lato:400,400i,700,700i|Merriweather:300,400,700" rel="stylesheet"> <link href="https://ma ...

How to Programmatically Assign Bootstrap Class to an Element Using Angular 2

I am working on a page with several input boxes that need to be flagged for certain criteria. <div class="form-group"> <label class="d-block">Allowance Type</label> <div class="input-group"> ...

Using CSS, you can utilize a three-dot pattern to create a unique X

Hey there! I've got a menu with three dots that animate, and when I click on them, I want them to transform into an X shape. You can check out the demo here: demo Here's the HTML: <div class="dots"> <div class="dot"></div> & ...

What is causing the col-auto with the red border to exceed its available height?

For this code, I've utilized version 5 of Bootstrap. In full screen width, the col-auto with the red border seems to be taking up more space than its content. The yellow border marks the available content space inside. I'm curious about what migh ...

Ways to pinpoint a particular division and switch its class on and off?

Consider this scenario, where a menu is presented: function toggleHiddenContent(tabClass) { let t = document.querySelectorAll(tabClass); for(var i = 0; i<t.length; i++) { t[i].classList.toggle="visible-class"; } } .hidden-conten ...

The hamburger menu on the navigation bar only functions the first time it is clicked

I've encountered an issue with my hidden menu nav bar. The hamburger and close buttons only work once. Should I organize the events within a function and call it at the end, or perhaps use a loop for the button events? It's worth noting that I d ...

Ways to initiate animation using CSS when the page loads

Is there a way to initialize the counter on page load? Even though I was successful in making it start on hover, I couldn't figure out how to make it work when the page loads. Here is the JavaScript code: var root = document.querySelector(':root ...

JavaScript function to change colors dynamically using Sass and Bootstrap

Has anyone ever tried to change the colors of Bootstrap Sass with just a click of a button? I've searched online, but had no luck finding any information. I appreciate any assistance! ...

Ensuring the HTML5 video poster matches the dimensions of the video content

Is there a way to adjust the HTML5 video poster so it perfectly fits the dimensions of the video itself? Check out this JSFiddle demonstrating the issue: http://jsfiddle.net/zPacg/7/ Here's the code snippet: HTML: <video controls width="100%" h ...

selectors that seem to be floating

I attempted to line up certain selectors horizontally on the same line using float:left. However, it did not work as expected! Could someone please assist me with this issue? http://jsfiddle.net/6YKhT/ ...

Troubleshooting the issue with the <div> tag in ASP.NET MVC 2 and the "float: left;" property. Any solutions to

Issue with the usage of <div> elements Everything runs smoothly: Text "Whatever" appears in column 1, followed by a radio button: No issues here (text without a radio button): The cell immediately following the text "Whatever" should display in co ...

Stylesheets may not display correctly in Firefox and IE

Just wanted to say that I recently put together this little website , but I am completely stumped on why the CSS file won't show up in Firefox or IE. I know it's a basic question, but I'm still learning all of this. Thank you so much for a ...

The Jquery css on my website is not functioning properly

After creating a website feature where clicking on a specific div triggers an onclick event processing a chat_generate function, I encountered some issues. This funciton should insert HTML for the chat into a designated .open_div based on the id generated ...

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 ...

What is the best way to incorporate padding that scales with the browser's width while centering content using `display: table;`?

^As mentioned in the title^. I am looking to adjust padding based on the width of a browser. My attempt so far has been: html, body{ height: 100%; } body{ display: table; margin: 0 auto; } #center{ display: table-cell; vertical-align: middle ...

If the navigation menu contains sub-menus, it should slide to the left

I am currently working on developing a navigation menu with four levels of depth. The menu displays three levels at a time, and when the user reaches the fourth level, the first level should move to the left to make room for the second, third, and fourth l ...

What is the process for inserting a hyperlink onto an image within a query slider?

I am experiencing difficulties when attempting to add hyperlinks to the images in my slider. I have come to understand that images cannot be clickable in jQuery sliders, so I have tried the following in the HTML: <div class="wrapper"> <div class= ...

Text being enveloped in a span tag

Currently, I have a table displaying a list of users with their corresponding roles. However, the roles column is sometimes wrapping before reaching the end of the line. The user list data looks like this: $scope.userList = [{ "id": 1, "name":"AB ...

Leverage CSS styling for database values within a PHP framework

How can I style MYSQL database values in HTML using CSS? My vegetarian database row has 'Y' for yes and 'N' for no. I want to apply different styles to these values using CSS as I display them on my PHP-based page. if ($result1->num_ ...

The filter on the mobile version is not displaying correctly

When I select a category in the input filter, only items with the same category are displayed when clicked. However, when I click on "Others" on the desktop version, only rows with that category are shown, but on mobile after resizing and filtering, nothin ...