Maintain consistent content height within a Bootstrap card

I have two Bootstrap cards and I want to ensure they maintain the same height, but the content inside .card-body

<div class="col-md-6">
    <div class="card">
        <img class="card-img-top" data-src="holder.js/100px180/" >
        <div class="card-body">
            <p class="card-text">Cost $100</p>
            <p class="card-text">Description: Beautiful item Lorem ipsum dolor sit, amet consectetur adipisicing elit. Voluptatibus </p>
            <button class="btn btn-danger">Buy</button>
          </div>
        </div>
      </div>
      <div class="col-md-6">
        <div class="card">
          <img class="card-img-top" data-src="holder.js/100px180/" >
          <div class="card-body">
              <p class="card-text">Cost $100</p>
              <p class="card-text">Description: Beautiful item Lorem ipsum dolor sit, amet consectetur adipisicing elit. Voluptatibus aspernatur sed alias reiciendis deleniti amet doloribus, adipisci aut, veniam asperiores ipsam nemo vel eius. Tenetur a eius vel impedit officia?</p>
            <button class="btn btn-danger">Buy</button>
        </div>
    </div>
</div>

The issue is that the content inside .card-body is causing the card borders to extend unevenly. Adding extra padding didn't resolve the problem. How can I ensure both cards have the same height while keeping the content aligned?

I also attempted using .d-flex .align-items-stretch, however, the content in .card-body became misaligned.

https://codepen.io/motorocool/pen/BadaWee

Edit: I am aiming for a similar outcome like this. https://i.sstatic.net/lloYA.jpg

Answer №1

<div class="box h-100">
on every box or using css:

box {
height:100%;
}

To ensure uniformity in the content within the boxes, you can view my implementation on jsfiddle

https://codepen.io/todor-markov/pen/jOLOLgP

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

Struggling with css margins and div image constraints, seeking guidance and tips for resolution

Struggling with creating a dynamic gallery that works smoothly in jsfiddle but encounters multiple issues when integrated into WordPress. The main problem is the excessive stretching of margins between image titles and meta-data, leading to misalignment an ...

adjust the transparency level of the background color for a div element that is compatible with Internet Explorer

Looking for a way to adjust the opacity of a div's background? This is easily done in modern browsers such as Chrome and Firefox using rgba. However, I'm facing difficulties with IE7. The "filter: alpha(opacity=50);" property doesn't work f ...

There is no data in $_POST when using php5.6

I have exhausted all the solutions on clearing $_POST after submitting a form on Stack Overflow, but none of them resolved my issue. I am currently using Wamp server and PHPStorm. Adjusted post_max_size and upload_max_filesize values in php.ini $_GET is ...

Access several different dynamic URLs through a single Ajax request

I have a scenario where I am showing multiple dynamic links within the same div. The first link works perfectly fine with ajax loading the content, but the subsequent links do not work. How can I make it so that the content of all links can be loaded withi ...

tips for showing inlinesvg in internet explorer 8

Can anyone assist me with displaying inlinesvg polygons with links in IE8? Is there a jQuery script or any other solution available? <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width= ...

Access a designated tab within a CSS-designed tab system

Can anyone offer some assistance? I currently have a tab structure created using CSS. The first tab is set as the default when the page loads. I am looking to create a link from another page that will take users directly to the page with the tabs and ope ...

Embed a video clip into an HTML webpage

I attempted to embed a video using HTML. I followed the player script instructions and added the necessary paths and scripts, but unfortunately, the video is not visible on the webpage. Instead, when clicking on the area where the video should be, it opens ...

Performance challenges with an AngularJS application that uses pagination

Resolving Performance Issues in Paginated AngularJS Posts Application I developed a compact application that showcases JSON data as cards using AngularJS and Twitter Bootstrap 4. The app includes pagination with approximately 100 posts per page. var ro ...

It is not possible to decrease the size of the image that is currently used as the background image

Three images are arranged in this manner: https://i.stack.imgur.com/u4PdK.png The HTML code for this setup is as follows: <div class="lb-controlContainer"> <div class="lb-closeContainer"> <a class="lb-close"&g ...

Selecting options using AngularJS to parse through a list

I am faced with a challenge involving a collection of strings representing years. Here is an example: $scope.years = ["2001", "2002", "2003", ...]; My goal is to display these values in a select tag within a web page. However, whenever I attempt this usi ...

Issues with the display property

After setting the display of a div tag as none in the style property, I am trying to show it based on an on-click function. However, the issue I am facing is that when I click on the function, the div displays for a brief moment then disappears again. Ca ...

The hover effects cease before the cursor is even shifted

Can someone explain why the hover effect stops before the mouse is moved off the element? I implemented the hover effect on a before pseudo element. ...

Initial value preselected for radio button

Is there a way to ensure that the Default radio button selected in the following code is always "Period"? Currently, when the page loads, none of the radio buttons are selected. <tr> <th valign="top" align="left"> Scope ...

Steps to create a clickable button wrapper label in React

Contained within the components below: <CheckboxGroupLabel htmlFor={option.label}> <FormCheckbox onClick={() => onChange} key={option.label} defaultChecked={defaultChecked} {...rest} /> {option.value} ...

What is the best method to update numerous low-resolution image sources with higher resolution images once they have finished loading?

I'm currently developing a website that implements a strategy of loading low-resolution images first, and then swapping them for high-resolution versions once they are fully loaded. By doing this, we aim to speed up the initial loading time by display ...

The dropdown menu is not being displayed, and instead the title is showing a message that says "Nothing Selected." Please review the code for any

I've been attempting to automatically select an option in a dropdown menu, but for some reason it's not displaying the dropdown and instead showing "Nothing Selected" as the title. I tried using opt.setAttribute("selected", "selected"); in my cod ...

The issue of ngx-bootstrap tabs persisting even after removal

I have implemented a method that resembles what can be seen on the demo site My objective is to display tabs for each record, with some records having just one tab and others having multiple tabs. While it seems like the correct number of tabs is being di ...

What are the steps to retrieve the URL for submitting a form action?

I am facing an issue where the form action file is located in another directory, but some files need to be sent to this action file. How can I obtain the URL to send the action? -> The action needs to be directed to http://www.123456.com/ac.php Is t ...

What are some ways to prevent "window.onbeforeunload" from appearing when a form is submitted?

Is there a way to prevent the alert box from appearing when submitting a form using the Submit button below? I want to avoid being prompted to "Leave this page" or "stay on this" after submitting the form. <script> window.onbeforeunload = ...

Choose the descendant element of the element that has a specific attribute

One of the issues I am facing is related to a button with a span tag inside for the text. Occasionally, this button might be disabled, and my goal is to have it appear grey when in that state. However, I am encountering difficulties making this work proper ...