Creating an eye-catching display with Bootstrap 4: Achieving a row of cards with varying heights

Is there a way to set up two cards next to each other in a row without one resizing to match the other? Whenever I resize the page, the cards no longer stay adjacent and collapse onto separate rows with different sizes. Manually setting the height works, but since the content will be dynamic, that's not ideal. Any suggestions on how to achieve this?


  <div class="row justify-content-center">
    <div class="card mb-4 ml-2 mr-2 text-left">
      <div class="card-body">
        <p>blahblahblah</p>
      </div>
    </div>
    <div class="card mb-4 ml-2 mr-2 text-left">
      <div class="card-body">
        <p>blahblahblahblahblahblah (long content) </p>
      </div>
    </div>
  </div>

CSS:
.card {
width: 36rem;
}

How they look (without forced height)

How I want them to look (this is by manually styling their height, which I want to avoid)

How they look when shrinking the page (this is fine, just for reference)

https://jsfiddle.net/fu7q6jca/

Answer №1

Remember, the .row class is meant to contain col-s, not cards. Make sure to place the cards inside the appropriate col-*...

<div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card mb-4 ml-2 mr-2 text-left">
                <div class="card-body">
                    <p>Unique text goes here</p>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="card mb-4 ml-2 mr-2 text-left">
                <div class="card-body">
                    <p>More unique text goes here</p>
                </div>
            </div>
        </div>
    </div>

Link to additional resources

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

Utilizing a relative path in CodeIgniter

I've been encountering a challenge with relative paths while using codeigniter in my app. Let me explain the situation: root/application/views/assets/css/style.css root/application/views/templates/file.php So, in the file.php, I reference style.css ...

Hiding and showing div elements using CSS, JavaScript, and PHP

Here is the current code snippet: <? while ($row1 = mysql_fetch_object($result1)) { echo '<a href="#" onclick="showhide("'.$row1->id.'");">Name</a>'; while ($row2 = mysql_fetch_object($result2)) { ...

How to retrieve text content from a span element with Selenium WebDriver and C#

I am at a mental roadblock and can't figure out this puzzle. My goal is to retrieve the number "9" from the span with id = "lookupCount". No matter how much effort I put in, I just can't seem to make it work. Please lend me a hand, here is the pr ...

Searching for effective methods to deliver reset password notifications to users

Seeking advice on sending password reset emails to users who have forgotten their passwords. Interested in various suggestions and methods for implementing this feature. I have a simple script that prompts users to click a 'forgot password' link ...

What could be causing the audio to not function properly on the webpage I'm working on that has yet to be launched?

As I work on my webpage, I am attempting to incorporate an audio file from SoundCloud. However, it seems that the file is not playing when sourced directly from the SoundCloud website. It works fine when the source is a file stored on my computer. <aud ...

Excess background spills beyond the width of the window

Looking to create a design similar to the following: A main container with 'n' child elements that may extend beyond the width of the window, causing the page to scroll horizontally instead of wrapping to the next line. This main container ...

Is it possible to use jquery to specifically target classes?

I am trying to achieve the following: $('.class.img').css('cellpadding', variable); However, this code does not seem to be working as expected. Despite searching online, I have not been able to find a solution. Any assistance on how to ...

Scraping data from a support portal using JSOUP

I am currently learning how to utilize jSoup for web scraping purposes on this specific portal that focuses on LAN switching and routing discussions. Link to the portal My goal is to extract information from a list of topics, specifically identifying sol ...

Utilizing the hcSticky plugin for creating a scrolling effect on webpage content

I'm attempting to utilize the JQuery plugin, hcSticky, in order to achieve a scrolling effect on my fixed content. However, I seem to be encountering some difficulty getting it to function properly. What could I possibly be doing incorrectly? JSFIDDL ...

Fix the uneven shape border/outline

I made 3 circles using CSS (:after) and noticed that the border looks uneven with certain background colors. Any suggestions on how to resolve this issue? You can view the problem here: Just below the post title, you'll find the first blue circle bo ...

Submitting a form from outside the form using a button in HTML: A step-by-step guide

I'm looking to submit a form using Angular on the functions next() and saveStep(). I'm unable to place next() and saveStep() within the form itself. I have set up my ng-click for next() and saveStep() below the form. When I submit the form fro ...

Incorrect modal placement

I am new to CSS and currently working on customizing a modal window. My main issue lies with its positioning, especially when the browser resolution changes, causing a misalignment as seen in the screenshot. I would like to specify the width and height dim ...

Having a concise way to submit forms with Javascript and JQuery

Seeking a more concise way to submit form data to Electron in JSON format as a beginner in JavaScript and jQuery. How can this code be rewritten for brevity? <section> <input id="server" type="text" placeholder="Server"> <i ...

What is the process for writing <p></p> and showcasing it on your website?

Is there a way to display the code <p></p> as text on an HTML page without it being processed as HTML, resulting in an empty paragraph? ...

When seen on a mobile device, the background image is set to repeat along the

Having trouble getting my background image to repeat on the y-axis when viewed on a mobile device. On desktop, the page doesn't scroll and the background image fills the screen perfectly. However, when switching to tablet or mobile, scrolling is neces ...

Using JavaScript to store CSS style properties in an array

In the midst of building a React-datagrid project, I am streamlining CSS properties for an array. However, there seems to be redundant CSS properties that I would like to consolidate into an array format. let _columns = []; let commonStyle = {"width":"20 ...

What steps can I take to prevent already selected options from being chosen in a Vue.js HTML form?

Among my json data, I have a list of all inventories: { "status": true, "data": [ { "inv_id": 1, "name": "Arts" }, { "inv_id": 2, "name": "web" }, { "inv_id": 3, "name": "mobileapp" }, { "inv_id": 4, "name": "ws" }, { "inv_id": 5, ...

Unable to manipulate Bootstrap styles in Angular 7 application

Attempting to customize the styling of my breadcrumbs in an Angular App by removing the divider is proving challenging. I've referenced https://getbootstrap.com/docs/4.2/components/breadcrumb/#example, but unfortunately, it's not yielding the des ...

HTML Techniques: Flipping the Script - Writing Characters from Right to Left

In order to showcase the temperature in degrees Celsius, I have implemented a placement technique using absolute positioning. Consequently, the °C symbol will persist in its designated spot. To achieve the desired presentation, the text should be displaye ...

Dynamically update selectable dates in Bootstrap datepicker based on availability

I've integrated WMS data into my website using Leaflet and have implemented a bootstrap datepicker that restricts date selection to a predefined array of dates by utilizing the beforeShowDay method. Now, I'm faced with the challenge of updating ...