Consistently sized and evenly proportioned, regardless of the amount of content within the card body

Is there a way to make these cards uniform in size and width? Whenever I add more text to a product on a card, the body shifts down while the edges of the card stay the same. I want the body to stay aligned regardless of the content. Is this possible?

<div class="card-body">
            <div class="product-name col-12 no-padding">
                <a
                    class="unset"
                    :title="product.name"
                    :href="`${baseUrl}/${product.slug}`">

                    <span class="fs16">{{ product.name.substring(0,20) }} <br> {{ product.name.substring(21,40) }} <br> {{ product.name.substring(41,60) }} <br> {{ product.name.substring(61,81) }} </span>
                </a>
            </div>

            <div class="sticker new" v-if="product.new">
                {{ product.new }}
            </div>

            <div class="product-price fs16" v-html="product.priceHTML"></div>

            <div
                class="product-rating col-12 no-padding"
                v-if="product.totalReviews && product.totalReviews > 0">

                <star-ratings :ratings="product.avgRating"></star-ratings>
                <a class="fs14 align-top unset active-hover" :href="`${$root.baseUrl}/reviews/${product.slug}`">
                    {{ __('products.reviews-count', {'totalReviews': product.totalReviews}) }}
                </a>
            </div>

            <div class="product-rating col-12 no-padding" v-else>
                <span class="fs14" v-text="product.firstReviewText"></span>
            </div>

            <vnode-injector :nodes="getDynamicHTML(product.addToCartHtml)"></vnode-injector>
        </div>
    </div>

Answer №1

In this demonstration, I showcase a pure CSS + HTML solution. The main objective is to illustrate how to standardize the size of card bodies.

HTML

<div class="container">

    <!-- Page Features -->
    <div class="row text-center">

        <div class="col-lg-4 col-md-6 mb-4">
            <div class="card h-100">
                <img class="card-img-top" src="https://dummyimage.com/600x400/000/fff&text=1" >
                <div class="card-body">
                    <h4 class="card-title">card 1</h4>
                    <p class="card-text">product1 </p>
                    <p class="card-text">product1 </p>
                    <p class="card-text">product1 </p>
                </div>
                <div class="card-footer">
                    <a href="#" class="btn btn-primary">+info</a>
                </div>
            </div>
        </div>
        <div class="col-lg-4 col-md-6 mb-4">
            <div class="card h-100">
                <img class="card-img-top" src="https://dummyimage.com/600x400/000/fff&text=2" >
                <div class="card-body">
                    <h4 class="card-title">card 1</h4>
                    <p class="card-text">product1 </p>
                    <p class="card-text">product1 </p>
                    <p class="card-text">product1 </p>
                    <p class="card-text">product1 </p>
                    <p class="card-text">product1 </p>
                </div>
                <div class="card-footer">
                    <a href="#" class="btn btn-primary">+info</a>
                </div>
            </div>
        </div>
        <div class="col-lg-4 col-md-6 mb-4">
            <div class="card h-100">
                <img class="card-img-top" src="https://dummyimage.com/600x400/000/fff&text=3" >
                <div class="card-body">
                    <h4 class="card-title">card 1</h4>
                    <p class="card-text">product1 </p>
                    <p class="card-text">product1 </p>
                    <p class="card-text">product1 </p>
                    <p class="card-text">product1 </p>
                    <p class="card-text">product1 </p>
                    <p class="card-text">product1 </p>
                    <p class="card-text">product1 </p>
                </div>
                <div class="card-footer">
                    <a href="#" class="btn btn-primary">+info</a>
                </div>
            </div>
        </div>



    </div>


</div>

run @ codeply

The crucial class to note is h-100 @ card tag.

Best of luck!

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 are involved in setting up a single form for entering orders, complete with both an order table and an order_item table that incorporates a foreign key

As I contemplate the best way to structure my page and forms for a customer ordering process, a few questions arise due to the tables' organization. To adhere to normalization standards, I have separated the order table and the order items table, link ...

Mobile phone experiencing issues with background loop video playback

<video autoplay muted loop id="videobg"> <source src="bgvideo/bgvideo.mp4" type="video/mp4"> </video> I have a background video on my website that works perfectly on desktop but not on iPhone. You can c ...

The Jade template is not rendering the page correctly as anticipated

I'm working with Node.js & express, using the Jade template for the view. My issue is that the Test text is currently hidden under the black navigation bar. How can I move it to the bottom, below the navbar? What am I missing in my code? Here is the ...

I am looking to specifically target and write to a particular line in a text file using PHP

What I am searching for: file.txt: Name: John email: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="abcdefghij">[email protected]</a> Here is my code snippet: <?php $myFile = "file.txt"; $txt = &apos ...

When the tailwind utilities are implemented, they do not appear on the screen

Recently, I embarked on a project using Tailwindcss/Next.js and encountered an issue when trying to apply a box-like shadow to a button with a new utility in pure CSS. Despite my efforts, the changes don't seem to take effect. Can you spot what I migh ...

Guide to modify target blank setting in Internet Explorer 8

<a href="brochure.pdf" target="_blank" >Click here to download the brochure as a PDF file</a> Unfortunately, using 'target blank' to open links in a new tab is not supported in Internet Explorer 8. Are there any alternative solutio ...

Is it secure to allow a specified group of harmless HTML tags from a request?

From my experience as a web developer, I've learned to be cautious when accepting HTML from clients. In my work, I rely on a WYSIWYG editor like TinyMCE for generating HTML content. While I've only used it on admin pages so far, I'm now cons ...

The table is too wide for its parent mat-nav-list, stretching to 100%

Here is the code snippet I am using to display a table inside a mat-nav-list: <mat-nav-list> <table> <tr>Node Information</tr> <tr> <td>Name</td> <td *ngIf="activeNod ...

Create a list of items that are enclosed within a parent element

My menu is generated from a php query and the output is as follows: #ultra-menu { width: 92%; background-color: rgba(255, 255, 255, 0.90); position: absolute; left: 0px; right: 0px; margin: auto; border-radius: 35px; max-height: 300px; ...

Populate a div with divs using automatic margins (CSS)

I know this question has probably been asked before, but I've searched high and low and can't seem to find an answer. It seems like my front-end skills are lacking when it comes to searching for solutions. Apologies in advance if this is a redun ...

Identifying when a user is idle on the browser

My current project involves developing an internal business application that requires tracking the time spent by users on a specific task. While users may access additional pages or documents for information while filling out a form, accurately monitoring ...

Is there a way to determine the precise location of the scrollbar within a div element?

Is there a way to obtain the exact position of the scrollbar (scrollY) for a specific div, rather than the entire window? I found an example that seems similar to what I need at the following link: http://plnkr.co/edit/45gKhAIt0DrozS7f0Bz2?p=preview Ho ...

Create two grid components for Material-UI and use Flexbox to ensure that both items have equal height

I'm currently working on ensuring that two grid items have the same height using flex in Material UI, but I've hit a roadblock. It seems like my approach with the Grid element might be incorrect. I've experimented with adjusting the height a ...

Triggering the 'Next' function with a key press event

Currently, I am utilizing the following code to manage the keydown event for the tab and enter keys within an input field. $(document).on('keydown', ".className" , function(e) { var keyCode = e.keyCode || e.which; alert(keyCode) / ...

Vuetify's scrolling list feature allows for smooth navigation through a list

Check out my Vuetify code snippet that utilizes a list: <v-list> <v-list-tile v-for="user in users" :key="user.id" avatar @click="" > <v-list-tile-content> < ...

Enhance the functionality of your website by implementing a zoom feature

I am looking to dynamically change the CSS of a div using jQuery when it is clicked. The challenge I am facing is that there are multiple divs with the same class and I am unable to modify their classes as they are created dynamically using PHP. <div ...

"Switching Classes with a Click Event: A Step-by-

This script is designed to work with SoundCloud's widget in order to enable remote text buttons. I am attempting to modify it so that it functions as a remote for an image button that toggles between different pictures for pause and play, rather than ...

How can jQuery be used to target a specific class based on its inner value?

For instance, within a div of the same class, there are 6 "p" tags - some containing 'member' text and others not. I aim to use jQuery to select all "p" tags with 'member' as their inner text and apply an additional class to them. Here ...

The event handler attached to the 'click' event will only be triggered upon the second click

After implementing the script, I noticed a strange behavior. When I click it on load, everything works perfectly. However, when I click it via a dynamically created element, the HTML seems to shift or stretch on the first click before returning to normal. ...

Difficulty with Vue.js updating chart JS label names

I have been working with Vue JS and implementing a chart in my single page application. However, I am encountering difficulties updating the Legend and despite numerous attempts and searches, I am unable to get it to update. Any assistance in correcting my ...