Ensuring Uniform Card Sizes in Bootstrap 4 for Multiple or Single Cards

Having trouble creating a page with N cards (single or multiple):

https://i.sstatic.net/20WXc.png

A single card appears like this:

https://i.sstatic.net/01bP0.png

I am unsure why the single card is not rendering correctly compared to multiple cards.

This is the HTML for the card:

<div class="card text-white bg-danger">
  <div class="card-header">
    <div class="row">
      <div class="col col-xs-3">
        <i class="fa fa-euro">{{expenseItem.amount}}</i>
      </div>
      <div class="col col-xs-9 text-right">
        <div class="d-block huge">{{count}}</div>
        <div class="d-block">{{label}}</div>
        <div class="card-body">
          <div class="row">

          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="card-footer">
    <span class="float-left">Details </span>
    <a href="javascript:void(0)" class="float-left card-inverse">
      <span ><i class="fa fa-arrow-circle-left"></i></span>
    </a>
  </div>
</div>

The card is supposed to be inside a component that should display a list:

<div class="container">
  <div class="row">
    <hr>
  </div>
  <div class="row">
  <div class="page-header">
    <h1 >Comp header</h1>
    <h4> total epenses per month {{expenses.total}}</h4>
   <app-pagination [paginationSize]="limit" [total]="total" (requierdPage)="getPage($event)"></app-pagination>
  </div>
  </div>
  <hr>
<!--<div class="row" >
    <div class="col-xs-3 col-lg-4" *ngFor="let expense of expensesList" >
       <app-expnses-item [expenseItem]="expense"></app-expnses-item>
    </div>

 </div>-->
<!--<div class="container">
  <div class="row">
    <div class="card-deck" *ngFor="let expense of expensesList">
      <app-expnses-item [expenseItem]="expense"></app-expnses-item>
&lt;!&ndash;      <div class="card">
        <div class="card-block">
          <h4 class="card-title">Card title</h4>
          <p class="card-text">This is a wider
            card with supporting text below as a natural lead-in to additional content.
            This content is a little bit longer.This is a wider
            card with supporting text below as a natural lead-in to additional content.
            This content is a little bit longer.</p>
          <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
        </div>
      </div>&ndash;&gt;
    </div>
  </div>
  </div>-->
  <div class="row" >
    <div class="col-sm-6 col-xs-6 col-xl-6 col-md-6 col-lg-6" *ngFor="let expense of expensesList">
    <app-expnses-item [expenseItem]="expense"></app-expnses-item>
    </div>
  <div class="row add">
   <div class="col-xs-1 offset-xs-1 align-self-sm-end">
     <i class="fa fa-plus-square-o fa-4x" aria-hidden="true" (click)="Uopen()"></i>
   </div>
   <app-add-expense (onFormSubmitted)="onDataSubmit($event)"></app-add-expense>
  </div>
</div>

Not sure what I'm doing wrong here. Any insights?

Answer №1

When using the .card-deck, it is recommended to place it directly within the container rather than inside a row. The .row class is designed for flexbox and should only be used to contain grid columns (col-*) that are not being utilized for the .card-deck.

<div class="container">
    <div class="card-deck">
        <div class="card text-white bg-danger">
        </div>
        <div class="card text-white bg-danger">
        </div>
        (repeat 1..n cards)
    </div>
</div> 

Visit this link for more information

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

Utilizing AngularJS and PHP to power an email submission form

I'm encountering an issue where the email I'm sending with AngularJS and PHP has empty parameters like name, email, etc. Despite my efforts to validate input using AngularJS, the data doesn't seem to be reaching my email account correctly. ...

Incorporating a class into ever-changing Bootstrap Table rows

Looking to enhance my table rows with a class, excluding the header. Struggling to find a way to do this. Any ideas? This is the table in question: <table id="table" class="hidden table table-bordered table-striped table-hover"> <thead> ...

Guide on transferring object between two $states using ui-router

Visit this link for more information Expected Behavior Upon logging in, selecting a Ticker button is expected to trigger the display of matching Tags for that specific Ticker. Actual Results However, upon clicking a Ticker button after logging in, the ...

Unable to input any text into the form fields ( React.js - Bootstrap) - experiencing difficulty in entering values into the input fields

Although I can position the cursor on it, I am unable to input any values from my keyboard into the input fields. Everything else seems to be working fine - the form still submits (albeit with empty data due to the typing issue). What steps can be taken to ...

BootStrap CSS causing changes to jQuery Drag and Drop Plugin

I have encountered a strange issue where my jQuery Drag & Drop simulation plugin is malfunctioning when BootStrap's CSS file is included in the header. Below are two fiddles containing the exact same code except for the inclusion of Bootstrap's ...

What is the best way to create panels with a set height in bootstrap?

This is an example image I want to use: Is there a way to set a fixed height for all my bootstrap panels? <div class="col-md-3 padding-0"> <div class="panel panel-default"> <div class="panel-body" style="min-height: 10px; max-height ...

CSS animations - transitioning opacity in and out

Looking to add some CSS animations to a menu but running into some issues. I've got the code below for the menu to fade in on hover, but can't quite figure out how to make it fade out smoothly as well. I've tried a few approaches, but all I ...

Switching back and forth between classes prevents the animation from playing continuously, causing it to jump straight to the end

Currently, I am in the process of animating a hamburger menu with a unique twist. The idea is to have the top and bottom lines smoothly translate to the middle and then elegantly rotate into an X shape when clicked. My approach involves toggling between tw ...

Adjust the spacing between two elements "p" in a single row using flexbox

#imprint { background-color: black; color: #FFFFFF; display: flex; flex-wrap: wrap; padding: 15px; justify-content: center; } <article id="imprint"> <p>test</p> <p>test</p> </article> Is ...

Relocate the HTML checkbox to the left side of its width

I need an answer that utilizes only CSS, without any JavaScript. In a form, I have a checkbox as follows: <label for="autologin">Remember Me</label> <input type="checkbox" class="checkbox" id="autologin" name="autologin" value="1"> <d ...

Simple Design: Main Navigation Bar Positioned to the Right Side of the Master Page

I must admit, styling is not my strong suit and I could use some help. On my CSS page, I need the MasterPage Navigation bar to be on the left side. However, when I click on a link to go to a different page, I want the content to show up in the middle while ...

Rearrange the middle column to be the top column on smaller screens

I am trying to create a layout with 3 columns in a row. The challenge is to prioritize the middle column on top when viewed on small screens, with the left and right columns below it. To clarify, on large screens the order should be 1 2 3, while on small s ...

What steps can be taken to proceed with the promise chain following a retry attempt

When using restangular to make multiple calls to the backend, I encountered an issue where subsequent requests are dependent on the result of the first call. To address this, I attempted to implement retry logic to ensure that follow-up requests are execut ...

Using jQuery to locate text and apply a specific class

Explaining My HTML Structure: <div id="test-listing"> <article> <a>Some URL</a><h3>Some Text</h3> <p>Drink this coffee</p> </article> <article><a>Some URL</a><h3>Some Text</h ...

Utilizing the MVC Model binding seamlessly in conjunction with the Angular ng-bind attribute

My question is regarding a specific tag in my code that uses the ng-bind attribute to display boolean values: <span id="ShowFlag" name="ShowFlag" ng-bind="session.view.showFlag"></span> After posting the form, I want to bind this value to a p ...

What is the best way to create a deck of cards using cards of the same width?

Need help creating a responsive card deck with fixed-width cards in Bootstrap 4. I've included the code below, but it's not rendering responsively. Can anyone assist? <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4. ...

What is the best location for storing buddypress css files?

Recently, I set up buddypress on a fresh WordPress installation and am interested in developing a child theme with personalized styles. Following advice from the buddypress codex, I copied the buddypress theme from plugins > buddypress > bp-template ...

Clicking on an anchor tag to open a div does not result in sufficient scrolling on mobile devices

I am facing a simple issue that I need assistance with. I am attempting to use an anchor tag to navigate to a specific div on my website. While this works fine on my computer, when I try it on my phone, it does not scroll all the way to the bottom of the d ...

How to align several lines of text in a table cell

I've been trying to center multiple lines of text in a table cell using the table method, but no matter how many online guides and SO posts I follow, I just can't seem to get it right. What I'm aiming for is to have the text perfectly cente ...

Error encountered while attempting to send a delete request to MongoDB due to connection refusal

Recently, I've been diving into a Next.js tutorial that involves working with MongoDB. Everything seems to be running smoothly when testing my API endpoints with Postman. POST, GET, and DELETE requests all go through without any hiccups. However, thi ...