Issue with uniform sizing of Bootstrap card-deck components

I have set up a display of card decks to showcase a collection of articles pulled from a database. The code snippet I am currently using is fairly simple:

HTML

<div class="row">
    <div class="card-deck">
        <template is="dom-repeat" items="{{articles}}" as="article">
            <div class="col-12 col-md-4 mb-md-5">
                <div
                    class="card"
                    on-tap="showViewer"
                    data-id$="[[article.id]]"
                >
                    <img
                        class="card-img-top img-fluid vertical-image"
                        src$="{{getArticleImage(article)}}"
                        onerror$="this.src='{{defaultimage}}'"
                        alt="{{getArticleDescription(article)}}"
                    />
                    <div class="card-body d-flex flex-column justify-content-center py-2">
                        <div class="d-flex justify-content-start align-items-center mb-2">
                            <img class="icon-sm mr-2 img-fluid" src={{getFavIcon(article)}}>
                            <span class="medium-text">
                                {{getSources(article)}}
                            </span>
                        </div>
                        <p class="card-text primary-headline medium-text">
                            {{article.schema:headline}}
                        </p>
                    </div>
                </div>
            </div>
        </template>
    </div>
</div>

CSS

.vertical-image {
    width: 100%;
    height: auto;
    object-fit: cover;
    object-position: center;
}

.icon-sm {
    height: 20px;
    width: auto;
}

.medium-text {
    font-family: Raleway-Medium;
}

.primary-headline {
    font-size: 25px;
    line-height: 25px;
    text-align: justify;
}

As per the Bootstrap documentation, utilizing the card-deck class should result in all cards within the deck having equal width and height. However, I am not observing this behavior. You can view what I am experiencing in this image.

What would be the correct method to ensure consistency in both the size of the images within the cards and the dimensions of the cards themselves?

Answer №1

Take a look at this snippet. Hopefully, it will be useful.

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
    <div class="row">
        <div class="col-sm-4 py-2">
            <div class="card card-body h-100">
                This is a simple card block.
            </div>
        </div>
        <div class="col-sm-4 py-2">
            <div class="card h-100 text-white bg-danger">
                <div class="card-body">
                    <h3 class="card-title">Danger</h3>
                    <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
                    <a href="#" class="btn btn-outline-light">Outline</a>
                </div>
            </div>
        </div>
        <div class="col-sm-4 py-2">
            <div class="card h-100 card-body">
               Just a simple card-block with a little more text!
            </div>
        </div>
        <div class="col-sm-4 py-2">
            <div class="card h-100 border-primary">
                <div class="card-body">
                    <h3 class="card-title">Primary</h3>
                    <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
                    <a href="#" class="btn btn-outline-secondary">Outline</a>
                </div>
            </div>
        </div>
        <div class="col-sm-4 py-2">
            <div class="card h-100 card-body">
                Just a simple card-block.
            </div>
        </div>
        <div class="col-sm-4 py-2">
            <div class="card text-white bg-primary">
                <div class="card-body">
                    <h3 class="card-title">Hello</h3>
                    <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
                    <a href="#" class="btn btn-outline-light">Outline</a>
                </div>
            </div>
        </div>
    </div>
</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

The column is experiencing difficulty in dividing evenly

https://i.sstatic.net/TOgOl.jpghttps://i.sstatic.net/gDuet.pngThe column is not splitting properly. I want the bottom picture to be positioned below the picture above. Adjusted column and image sizes <div class=" container mx-auto mt-5 p-0"> ...

Removing margins in Bootstrap 5: A step-by-step guide

Currently facing an issue with removing margins in bootstrap. I am looking to set up two graphics that indicate the under construction status of the page - one for desktop and one for mobile devices. This is what I have tried so far: <!DOCTYPE html> ...

What is the reason behind IE's decision to reduce the size of password boxes compared to text

Take a look at the uncomplicated form right below. You'll notice that it consists of a text box positioned above a password box. In older versions of Internet Explorer like 7 and 8, as well as possibly in other browsers, you might observe that the tex ...

What is the best way to incorporate a badge into my Bootstrap site?

I am delving into the world of front-end development, starting with a Bootstrap project. However, I have hit a roadblock. I am trying to incorporate badges similar to those in my design, but every attempt throws off the alignment and messes up the layout o ...

Hiding and securing a div element when JavaScript is disabled

My form includes a <div>. This particular <div> is a red circle. Even when JavaScript is disabled, it remains visible (I can use display: none to address this). The issue arises when I re-enable JS - upon user interaction, the <div> mov ...

concealing the date selection feature on the data picker

$('.year').datepicker({ changeMonth: true, changeYear: true, showButtonPanel: true, dateFormat: 'MM yy', onOpen: function(dateText, inst) { $("table.ui-datepicker-calendar").addClass('hide') }, onClos ...

Dynamic water filling effect with SVG

I'm trying to create a wipe animation that looks like water filling up inside of a drop shape. Currently, it is a square with a wave animation on top of the drop logo. The wave animation works correctly, but I am struggling to contain it within the dr ...

When attempting to override the $primary variable in Bootstrap 4, it seems that the changes are not being applied to all other overridden Bootstrap variables in the _user

I am currently in the process of creating an HTML theme using BootStrap 4.3.1. My aim is to modify the $primary color variable in my _user-variables.scss file so that it affects all colors based on the theme specified in _variables.scss. I am relatively ne ...

Closing the modal by simply clicking outside of it's boundaries

Is there a way to close the modal by clicking outside of it using pure JS or AngularJS? I'm struggling to figure out how to implement this functionality. Any assistance would be greatly appreciated. View Fiddle .modalDialog { position: fixed; ...

Styling is not being applied to the DataTable when it is invoked through an ajax

I have developed a simple SpringBoot application using Spring Initializer, JPA, embedded Tomcat, Thymeleaf template engine, and packaged it as an executable JAR file. Within this application, I have implemented two datatables: one utilizing ajax and the ot ...

What is the best method for arranging various react components in sync?

I am striving to achieve a specific style. My current code looks like this: <Box display="flex" flexDirection="row" alignItems="center" width={1}> <Box flexGrow="1"> <Typography variant="h6 ...

Show an icon when the .table-responsive class in Bootstrap has horizontal scrolling

In my responsive table using Bootstrap (on Drupal), I have set an icon as the background in CSS. Is there a way to only display this icon when the table is too wide and requires horizontal scrolling? tablefield-wrapper .table-responsive { padding-top: 2. ...

What is the best way to position elements with CSS?

I need help aligning the arrows and images on the same line. Can anyone guide me on how to do this? (I'm using html5boilerplate). Desired Layout: Current Layout: Existing Code: HTML: <div id="linkbar"> <a><img src="./img/ar ...

How can jQuery be used to display the size and type of linked files in title attributes?

For instance: Prior to <a target="_blank" href="http://www.adobe.com/devnet/acrobat/pdfs/reader_overview.pdf"> Adobe Reader JavaScript specification </a> As the file is in PDF format, the title should read title="PDF, 93KB, opens in a new ...

Steps for declaring CSS values with fallbacks in case of unsupported values

I'm looking to utilize the overflow: overlay property in Chrome, and overflow: scroll in Firefox. Simply declaring the overlay value causes Firefox not to scroll at all, even though I know it's not standard. My question is: what's the optim ...

The vanishing HTML Div with a fixed height

After implementing a navigation bar inside my header container, I noticed that the main_image div with a blue background color disappeared. Despite setting a height for it, the div was nowhere to be seen. Additionally, the welcome_text div seemed to lose i ...

Utilize identical animations across various elements

I have a canvas animation in JavaScript that is currently limited to one canvas element with the id "stars". I want to be able to use this animation multiple times without repeating the code. Is there a way to add a class for the canvas elements instead of ...

Attempting to figure out how to make Bootstrap pagination function properly

I am trying to implement Bootstrap's pagination feature into my project. While I was able to find the HTML code for it on the official Bootstrap page, I am struggling to make the content change dynamically when I move to the next page. Can anyone pro ...

Allow a nested element to overlap its container instead of displacing it

As a CSS newbie writing a React app, this question may be the easiest one in the history of stackoverflow. I'm trying to make the image element overlap the header instead of pushing it down. In this basic HTML example, the cat image is stretching the ...

The link tag cannot be used inside a division element

I am facing an issue with a button that has three different states represented by images. While the button looks great and functions well, it fails to perform its primary function - linking to another document. Upon clicking the button, no action is initi ...