Achieving vertical alignment of content within a card using Bootstrap

Can someone help me create a card similar to this design?

Example Card

I'm having trouble aligning the items at the bottom like in this example:

My Card

Here is my code snippet:

<div class="container">
  <div class="row row-cols-1 row-cols-md-2 g-3 my-3">
    <div class="col">
      <div class="card text-uppercase">
        <img src="/../../assets/img/Affiliate_1fdd38b1-d99f-4d5a-b1ee-c4d30397dd2c_643x450.webp" class="card-img" alt="...">
        <div class="card-img-overlay">
          <h5 class="card-title">FUNCIONAL</h5>
          <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional
            content.</p>
            <a href="#" class="btn btn-primary">Go somewhere</a>
        </div>
      </div>
    </div>
    <div class="col">
      <div class="card text-uppercase show-bottom">
        <img src="/../../assets/img/Affiliate_1fdd38b1-d99f-4d5a-b1ee-c4d30397dd2c_643x450.webp" class="card-img" alt="...">
        <div class="card-img-overlay d-flex flex-column">
          <h5 class="card-title">FUNCIONAL</h5>

          <p class="card-text mt-auto">This is a longer card with supporting text below as a natural lead-in to additional
            content.</p>
            <a href="#" class="btn btn-primary mt-auto">Go somewhere</a>
        </div>
      </div>
    </div>
    
  </div>
</div>

I've attempted using the "d-flex" and "flex-column" classes within the "card-img-overlay" div, as well as adding "mt-auto" to the button class, but I haven't been successful.

Answer №1

If you want to enhance the design of your .card-img-overlay element, consider incorporating the following predefined classes:

d-flex flex-column align-items-start justify-content-end

For more information on these classes, you can refer to the official documentation here: https://getbootstrap.com/docs/5.3/utilities/flex/

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="177578786364636576675722392439273a767b677f7626">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="92f0fdfde6e1e6e0f3e2d2a7bca1bca2bff3fee2faf3a3">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>

<div class="card text-uppercase text-bg-dark" style="width: 500px;">
  <img src="https://rb.gy/18mzdx" class="card-img" alt="...">
  <div class="card-img-overlay d-flex flex-column align-items-start justify-content-end">
    <h5 class="card-title">FUNCIONAL</h5>
    <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional
      content.</p>
      <a href="#" class="btn btn-primary">Go somewhere</a>
  </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

Cutting imagery to create a new design element

https://i.sstatic.net/IAh0h.jpg There is an image above with 6 gears (circles with pointy edges). My goal is to separate them into individual pictures and, on each picture's hover, have a relevant line with text appear. How can I achieve this? The a ...

Modifying the image height in a column using Bootstrap and JSON data

My webpage is dynamically generating images from a JSON file through a JavaScript file. However, the images are displaying at different heights, and I want each column to adjust to the height of the image to eliminate any gaps. Particularly, data with the ...

Is there a way to make the button text bold before deleting it post clicking on an alert message?

While testing my sequence in IE, I noticed that it appeared correctly, but in Chrome, the button text was not showing up as bold. Instead, only the alert message was displayed, and the button itself was removed. Upon further investigation using Chrome&apo ...

html and css code to create a linebreak ↵

I received a JSON response from the server, and within this data is a "return line" in the text. {text: "I appear in the first line ↵ and I appear in the second line"} However, when I try to display this on an HTML page, the "return line" does not show ...

Utilize the full width available to create a flexible div element without any fixed sizes

I have come across similar questions, but none of them quite addressed my specific situation. My dilemma involves a tabbed navigation that can vary in size depending on the number of tabs added to it. Adjacent to the navigation, there is a second area hous ...

The function is not defined, even though it is located within the same file

I've encountered an issue with my web page where I'm trying to read data from an HTML data table and update it on a PHP file using AJAX queries in JavaScript. Everything was working fine until recently, even though I didn't make any signific ...

Problem with the placement of Google autocomplete dropdown

I'm currently utilizing the NgxAutocomPlace module within my Angular application. This module interacts with the Google Autocomplete API by generating a .pac-container to display autocomplete suggestions. However, I'm facing an issue where on mo ...

Ways to incorporate External JS and CSS files into Angular 5 (loading files with a delay)

I have encountered some challenges while attempting to import external JS and CSS files into my Angular 5 application. Below is the code snippet that I have tried so far: Component.ts : ngOnInit() { this.loadScript(); // also attempted with ...

What is the correct way to reset the styling of a web browser element, such as a <button>?

I have come across many sources advising me to reset HTML by manually resetting numerous individual properties, as demonstrated here: https://css-tricks.com/overriding-default-button-styles/ Another approach I discovered in CSS is simply using: button: {a ...

Switch the designation to Hover Class

I am working with nested divs and have assigned a CSS class to one of the inner divs. How can I trigger the hover effect of the class (class.hover) when the user hovers over the outer div, even if they are not directly over the inner div? I believe this m ...

Is it recommended to include the default declaration in the same stylesheet as the media queries?

In order to optimize my code structure, I placed the default declaration in the style.css file and kept all media queries separated in a stylesheet named enhanced.css. For instance, an example of a code snippet I have in the style.css looks like this: .b ...

Incorporating a complex React (Typescript) component into an HTML page: A Step-by

I used to have an old website that was originally built with Vanilia Javascript. Now, I am in the process of converting it to React and encountering some issues. I am trying to render a compound React(Typescript) component on an HTML page, but unfortunatel ...

Refresh the CSS inheritance and hover effects

Facing an issue with my web project where I am using CSS. At times, I need to reset the inheritance from the parent class for certain elements. Although I have defined some classes to style my elements, I want to completely reset all styles except for hove ...

arrange objects into an array depending on punctuation marks

Currently, I am in the process of developing a method to retrieve data from my MySQL database and present it as an array. However, the issue I am facing is that only one string of data is accessible at a time, with each instance separated by a comma. For e ...

Troubleshooting a problem with Select Dropdown in HTML and PHP

Hello, I am encountering an issue with a dropdown box as shown below: function createDropdown( $name, array $options, $selected=null ) { /*** starting the select element ***/ $dropdown = '<select name="'.$name.'" id="'.$name.'" ...

Ensure that the class is consistently assigned with identical col-md-* and col-lg-* properties across all instances

Bootstrap 5.2 is my framework of choice for targeting github pages, and here is a snippet of my code: <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" ...

Tick the checkbox to indicate that I want to insert an image in the adjacent column for the same row

Every time I click on the checkbox, an image should appear in the adjacent column for that specific row. Despite using the addClass() method and targeting the td, the image is appearing in all rows instead of just the selected one. Could somebody help me ...

What is causing the lack of response in the select box on Mac Chrome when I try to click on it?

Similar Question: JQuery function doesn't work on Chrome on Mac, but works on Chrome on Win 7 and all other browsers I am encountering an issue with a select-option list <div class="social-option"> <select name="hex_theme_options[soc ...

Spin and shift image of a ball using Html 5

Now the image will be moved without rotating. I have implemented moving functionalities, but it only supports IE10. Here is the script I am using: var ball = new Image; window.onload = function () { var c = document.getElementsByTagName('canvas&apos ...

Tips on dividing a CSS file into separate lines for improved readability

I came across a dilemma while working with a 3rd party CSS file that is all one long line. Both the Sublime 2 text editor and Eclipse CSS editor were unable to split the file into easily readable style blocks. Can anyone recommend tools or methods for bre ...