Is there a way to adjust the card quantity in a Bootstrap row using media queries?

<div class="col-xl-3 col-lg-4 col-md-6 col-sm-12" *ngFor="let card of cards">

This specific div is responsible for containing the various cards that are visible on the webpage. Depending on the screen size, a different number of cards will be displayed - 4 for XL, 3 for large, 2 for medium, and 1 for small screens.

However, when transitioning from one screen size to another, particularly between extra-large and large or from large to medium, there is an issue with overlapping cards horizontally on the page.

To address this problem, I utilized the @media selector in CSS and set the background color to red as a test. Here's how it was implemented:

@media (min-width: 1200px) and (max-width: 1450px) {
    background-color: red; // Testing application
}

@media (min-width: 990px) and (max-width: 1050px) {
    background-color: red;           
}

My inquiry revolves around how to adjust the number of cards displayed in each @media query. In the first @media tag, I aim to display only 3 cards instead of 4, while in the second @media tag, my goal is to show 2 cards rather than 3.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="87e5e8e8f3f4f3f5e6f7c7b3a9b1a9b5">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">

<div class="container-fluid">
  <div class="row">
    <div class="col-xl-3 col-lg-4 col-md-6 col-sm-12">
      <!-- insert card markup here -->
    </div>
  </div>
</div>

Answer №1

Modify col-xl-3 to col-xl-4 for 3 columns

Update col-lg-4 to col-lg-6 for 2 columns

The grid system in bootstrap consists of twelve columns.

col-size-x will show 12/x cards on the screen.

Ensure not to make changes to the media queries!

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

Mastering the art of mocking Rxjs Subject in an Angular application

I've set up a centralized DataStore to manage my report connections, handling events like onShow, onError, and onCancel so that the implementer doesn't need to worry about it. Now, I'm trying to figure out how to mock the SomeService.doSomet ...

Setting up a development environment for .NET Core 2.0 with an Angular template and website template that can be easily downloaded using NPM

Currently, I am embarking on a new project utilizing .NET Core 2.0 with the Angular template. My intention is to integrate an existing HTML template into my project. After some research, I opted for a free HTML template called Gentelella which I have to in ...

Is there a way to ensure that the div is displayed on the same line?

Check out the jsfiddle link provided: http://jsfiddle.net/HE7yT/ I'm trying to align the Image, content, and Amount in the same line. How can I achieve this? The goal is to have "150" displayed on the same line as the picture. var HTML = $(' ...

Options for Angular's routerLinkActiveDirective

I have a link that looks like this <li routerLinkActive="active" class="nav-item"> <a [routerLink]="['contracts']" [queryParams]="{ activeOnly: false }" class="nav-link">Contracts</a> </li> As you can see, in the param ...

Place a picture and words within a submit button

I need assistance with aligning text and a small airplane image on a submit button. Currently, the text is overlapping the image and I am unsure how to fix this issue. How can I adjust the position of the text to display to the right of the button? Is ther ...

Stylish CSS animation enhancing an image

Can a flash effect like the one in this image be created using only CSS? I attempted to use -webkit-filter, but it did not produce satisfactory results. https://i.sstatic.net/Eg49c.jpg ...

Provider for DateAdapter not found in lazily loaded third-party module

Within my application, I have implemented a custom DateAdapter using dayJs. Here is how the module providing it is defined: @NgModule({ providers: [ { provide: MAT_DATE_FORMATS, useValue: MAT_DAYJS_DATE_FORMATS }, { provide: DateAdapter, useClas ...

Sticky sidebar following a complete-page header

I recently added a fixed sidebar to my website: However, I'm facing an issue where the sidebar appears in front of my full-page header when I set its position to fixed. What I actually want is for the sidebar to start after the header as if it were p ...

At what point does a dynamically loaded CSS file in the head section of a webpage actually

If the answer is already out there somewhere, I would really appreciate a link because I just can't seem to find it. When loading .php pages, I either include 'header.php' directly with <?php include 'header.php'; ?> or on ...

What is causing the classList function to throw an error: Uncaught TypeError: Cannot read properties of undefined (reading 'classList')?

There's an error that I can't figure out: Uncaught TypeError: Cannot read properties of undefined (reading 'classList') console.log(slid[numberArray].classList) is working fine, but slid[numberArray].classList.add('active') is ...

If the children contain multiple div elements in jQuery

Is there a way to determine the number of divs inside a li element? Below is the code I've tried, but it's not functioning as expected. (The issue is that every img receives the class, even when there's only 1 div inside the li.) if($(&apo ...

"First Screen Scrolling initiates the functionality of the Bottom Sticky Menu

I previously had a sticky navbar positioned at the bottom of the page. It was functioning without any issues, but now I want the sticky navbar to only appear at the bottom of the page when the user scrolls down. .mobile-fixed-res { posit ...

The method TranslateModule.forRoot does not require a specific type argument and produces a ModuleWithProviders type

After upgrading my Angular application from version 5 to version 9, I encountered an error during the build process. The error message stated: "TranslateModule.forRoot returns a ModuleWithProviders type without a generic type argument. Please add a ge ...

Having trouble with vendor CSS not being recognized during brunch compilation

I am currently exploring the use of Pure.css in my application. After installing it via npm, I have configured my brunch-config.js as follows: stylesheets: { joinTo: { 'app.css': /^app/, 'vendor.css': /^(?!app)/ } } At thi ...

Troubleshooting Authorization Header Issue in Angular 5

I created an Interceptor to include an Authorization token in all HTTP Requests, but unfortunately it's not functioning as expected. I've double-checked my code and everything seems correct, so I'm wondering if there's something crucial ...

The case of the elusive Firefox overflow: hidden glitch

Recently, I integrated an image slider into my web design and it displayed perfectly on Internet Explorer and Chrome. However, when viewed on Firefox, I encountered a strange problem where the images in the slider were being pushed towards the right side o ...

Troubleshooting the Alignment Issue in Angular Material Expansion Panel Header

I have implemented an Angular 14 Material Expansion Panel as shown in the code snippet below... <mat-nav-list> <a mat-list-item role="listitem" class="list-item-setting" id="emailTemplatesId" matTooltipPosition=&quo ...

How come a child element with a lower z-index than its parent doesn't appear behind the parent?

I'm currently investigating why a child element fails to appear behind its parent element when it has a lower z-index value than the parent. The issue seems to arise only when the default z-index value of the parent is modified. Let's consider a ...

Increase the gap between columns in Bootstrap for a better layout

I have implemented a web layout using bootstrap 3. You can view the JSFiddle here. In order to make the layout responsive, I had to structure it in a slightly unconventional way. The final output on small screens includes three information boxes within an ...

The issue arises when trying to use data provided by a service, resulting in an "undefined

Looking to create a handler that generates an array of categories based on the presence of "categories" for a specific "resource". However, encountering an error with the last method. ERROR TypeError: "this.allProjectResources is undefined" import { Res ...