Attempting to line up two horizontal cards side by side in such a way that the bottoms of both images are perfectly aligned

Image showing misalignment of cards I've been struggling to align two horizontal cards so that the bottom of their images line up perfectly. This is the current HTML code I am working with:

 <div class="container">
    <div class="row">
      <div class="col">
        <div class="card w-100 d-flex flex-column">
          <div class="row">
            <div class="col">
              <div class="card-block">
                <h3 class="header">More Equipment</h3>
                <hr> 
                <p> This is some text and more text, lots of it! </p>
                <a href="#" class="btn btn-danger btn-sm">Read More</a>
              </div>
            </div>
            <div class="col">
              <img class="img-fluid w-100 h-100" src="images/airplane.jpeg" alt="">
            </div>
          </div>
        </div>
      </div>
      <div class="col">
        <div class="card w-100 d-flex flex-column">
          <div class="row">
            <div class="col">
              <div class="card-block">
                <h3 class="header">More Equipment</h3>
                <hr> 
                <p> More text in this card as well, tons of content! </p>
                <a href="#" class="btn btn-danger btn-sm">Read More</a>
              </div>
            </div>
            <div class="col">
              <img class="img-fluid w-100 h-100" src="images/Agility.jpeg" alt="">
            </div>
          </div>
        </div>
      </div>`

Along with the mentioned HTML, here is my CSS snippet:

                .card-block {
                  font-size: 1.2em;
                  position: relative;
                  padding: 1em;
                  border-top: 1px solid rgba(34, 36, 38, .1);
                  box-shadow: none;
                }

                .card {
                  font-size: 1em;
                  overflow: hidden;
                  padding: 5;
                  border-radius: .27rem;
                  box-shadow: 0 1px 3px 0 #d4d4d5, 0 0 1 1px #d4d4d5;
                  margin-top: 25px;
                }

                .img {
                  object-fit: cover;
                  height: 100%;
                  width: 100%;
                }


The current state of display can be seen in the provided image. My objective is for the images within both cards to align perfectly at their lower edges. All this work has been done utilizing Bootstrap Version 4.

I have experimented with this alternative set-up:

<div class="container">
    <div class="row">
      <div class="col-sm-6 d-flex align-items-stretch">
        <div class="card">
          <div class="row">
            <div class="col-sm-6 d-flex align-items-stretch">
              <div class="card-block">
                <h3 class="header">More Equipment</h3>
                  <hr> 
                <p> Yet more content for this card! </p>
                <a href="#" class="btn btn-danger btn-sm">Read More</a>
              </div>
            </div>
            <div class="col-sm-6 d-flex align-items-stretch">
              <img class="img-fluid d-flex w-100" src="images/airplane.jpeg" alt="">
            </div>
          </div>
        </div>
      </div>
    <div class="col-sm-6 d-flex align-items-stretch">
        <div class="card">
          <div class="row">
            <div class="col-sm-6 d-flex align-items-stretch">
              <div class="card-block">
                <h3 class="header">More Equipment</h3>
                  <hr> 
                <p> And additional text filling the second card entirely! </p>
                <a href="#" class="btn btn-danger btn-sm">Read More</a>
              </div>
            </div>
            <div class="col-sm-6 d-flex align-items-stretch">
              <img class="img-fluid d-flex w-100" src="images/Agility.jpeg" alt="">
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

In this layout, the bottoms of the cards are indeed aligned; however, the first card's image doesn't extend all the way to the bottom. You can view an illustration of this issue here: First plane image not lining up with bottom of second image

Answer №1

By applying the h-100 class to the row within the card class, I successfully resolved the problem at hand.

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

Store information in an array for a permanent solution, not just a temporary one

When adding entries to a knowledgebase using the following code, I encounter an issue where the entries are only available during the current session. Upon reloading the site, the entries are lost. Can you help me troubleshoot this problem? Here is a snip ...

Enhancing functionality with jQuery: updating multiple input fields at

Currently, I am attempting to utilize jQuery to modify some HTML text by adjusting a slider. I have managed to accomplish this; however, I also need it to happen only if a checkbox is checked. How can I integrate both conditions and ensure that the text ch ...

The font from the server is not displaying correctly in the local HTML file

After uploading the ttf font file to the server, I utilized the following CSS code: @font-face { font-family: "fontname"; src: url("http://www.mywebsite.com/Fonts/fontname.ttf"); } body { font-family: "fontname", sans-serif; } Within the loc ...

What is preventing my h1 styles from being applied to an h1 element within a <section> tag?

I have a headline in my header and in another part of the content. I've been told that this can impact SEO, but I'm just starting out by copying other people's pages and trying to replicate their styles without looking at their code. The st ...

Expanding and collapsing multiple div elements easily with Javascript code

I am exploring how to customize the expand/collapse functionality for multiple DIVs on my webpage. Currently, I have implemented a code snippet that toggles an entire class, but I am wondering if there is a way to target the specific element being clicked ...

What is the best way to adjust element size according to the screen size?

How can I use CSS to make a button element appear bigger on smaller screens? The current size is ideal for desktop screens but appears too small on mobile devices. <html> <header> <link rel="stylesheet" type="tex ...

Photo Collection: Incorporating Images

I am currently working on a project to create a photo gallery and I am facing an issue with adding photos. The user should be able to browse for a picture and enter a title for it on a page. Both the image path and title need to be saved in an XML file fro ...

Tips for wrapping and aligning elements in the center

On my website, I have a layout that displays 10 small images (around 100x200 pixels) evenly spaced at the bottom of the page. | | | The wide window la ...

Creating a dynamic Bootstrap 4 modal link directly within the Datatables.js plugin

I am currently utilizing the Datatables.js jQuery plugin to construct HTML tables (jQuery version 3.2.1). The HTML table generated by Datatables needs to include a clickable link in one of the column cells (author_id) that opens a Bootstrap 4 modal and sen ...

What are the steps for positioning the floating pane in dojo?

I have successfully created a floating pane declaratively using the code below. Everything seems to be functioning correctly, except for the fact that when I click the button to open the floating pane again, its position changes from the previous locatio ...

When I try to access my Ionic page, it fails to load and render properly. Additionally, clicking on the sidemenu link in my app does

I am currently developing an app using Ionic and AngularJS. I have created a page, but for some reason, the HTML content is not loading and only showing a blank screen. Clicking on the navigation link in the sidemenu does nothing, and Ionic doesn't ev ...

Tips for changing input box value according to row id

After analyzing the web screenshot, it appears that the time value is retrieved from the database column named 'settime'. My intention was to input a custom value into the 'settime' column and update that specific row. However, when I a ...

If the SASS condition matches the variable for the background color, then

I attempted to create a conditional statement in my component using Sass @if and @else. The condition I set was that if background == var(--bg-danger), the color should be white. However, it only returned white and did not trigger the else condition. @mixi ...

Producing identical sets of 2 random hues for a pair of distinct items

I am trying to figure out a way to assign the same randomly generated color to two separate objects. Does anyone have any suggestions on how I could link these two objects so that they always have matching colors, refreshed whenever a condition is met? T ...

Using an image as the background for a three.js scene may cause it to appear distorted

I am struggling with setting an image as a background for my scene without it becoming blurry. I have attempted to use the following code: textureLoader.load("images/background/space.png", function(t) { scene.background = t; }); The problem arises when ...

Tips for maintaining button alignment consistently horizontal on desktop devices, except when viewed on a mobile phone

On my larger monitor, the buttons are positioned in a row with three in line and the fourth one below. I would like to arrange them horizontally on desktop but stack them vertically on mobile devices. Is this possible? <!DOCTYPE html> <html> ...

Achieving Vertical Alignment of DIV and Text Using Bootstrap 4

After scouring through various questions, articles, and Bootstrap 4 documentation, I have yet to find the solution I am seeking. DEMO: https://jsfiddle.net/zxLLqsm0/ My goal is to create boxes with uniform height for all columns while vertically aligning ...

The mobile responsive view in Chrome DevTools is displaying incorrect dimensions

Seeking some clarification on an issue I encountered: I recently created a simple webpage and attempted to make an element full width using width: 100vw. However, I observed that on screens smaller than around 300px, the element appeared smaller and not t ...

Prevent the movement of the first column in a table when rearranging rows up or down by utilizing

Feeling a bit stuck here, can't seem to figure out what I've missed. I've managed to move up or down a row in a table, but I need the value of the cell in the first column to remain unchanged. Here's my code: This is my HTML file: &l ...

Unable to connect the index.html file with the style.css file located in a different folder

I'm having an issue linking my style.css file to my index.html file. They are both located in different folders. Here is the folder structure: /parent /src/index.html /css/style.css I have attempted using the following code snippets: <link re ...