Adjusting Card Size both Vertically and Horizontally in Bootstrap

After struggling to align my bootstrap cards for what feels like forever, I've decided to seek help by creating this post. Hopefully someone can assist me!

Initially, the cards were all the same width and stacked correctly, but the height was not consistent. They lined up in a row but only stretched to match the content's height.

I managed to find a solution that fixed the height issue by using d-flex align-items-stretch in the containing div. However, now on smaller devices, the height matches, but the width extends with the content. Any suggestions?

<section class="row ">
<div class="col-12">
    <h3 class="mb-4">Row Title</h3>
</div>

<div class="col-lg-6 mb-4 d-flex align-items-stretch">
    <div class="card">
        <div class="card-header">Card 1</div>
        <div class="card-block">
            <p><b>Overview:</b> Text 1<br><br>
            <b>More:</b> Text 2<br><br></p>
            <button class="btn btn-secondary margin" type="button"><span class="fa fa-check"></span> &nbsp;Go</button>
            <button class="btn btn-secondary margin" type="button"><span class="fa fa-file"></span> &nbsp; Information</button>

        </div>
    </div>
</div>

<div class="col-lg-6 mb-4 d-flex align-items-stretch">
    <div class="card text-white bg-success">
        <div class="card-header">Card 2</div>
        <div class="card-block">
            <p><b>Overview:</b> Text 2</b></p>
            <button class="btn btn-secondary margin" type="button"><span class="fa fa-check"></span> &nbsp;Go</button>
            <button class="btn btn-secondary margin" type="button"><span class="fa fa-file"></span> &nbsp; Information</button>
        </div>
    </div>
</div>              

https://i.sstatic.net/aDvW4.jpg

Answer №1

To make the cards stretch/fill horizontally, you can utilize w-100.

For more information, visit:

Keep in mind that as of Bootstrap 4.0.0, the padding class card-block has been changed to card-body for consistency within the cards.

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 is the optimal frequency for saving data when dealing with a particularly extensive form?

I am facing a challenge with saving data to the database using Ajax. While I can handle this aspect, my difficulty lies in the fact that I have a very extensive form that is nested and cannot be altered. This large form consists of approximately 100 input ...

Using HTML in conjunction with Javascript, the window.prompt function can be

As someone who is brand new to javascript and html, I wanted to create a simple example that takes user input and displays it in a table. However, I'm struggling to get the window prompt to show up. I have a feeling that I am making a very obvious mis ...

Distinguishing Response Headers in XMLHttpRequest and jQuery AJAX FunctionUniqueness:

Hello, I'm facing an issue that is not a duplicate. Here is the code snippet: var data = {'userId': window.cookie.get('userId'), 'sessionId': window.cookie.get('sessionId')} $.post(window.DbUrl + '/t ...

Optimizing React+ReactRouter web app loading times by efficiently splitting and loading CSS using WebPack

I am encountering a delay in the initial loading of my web app, even after implementing various improvements like using only critical CSS during server side rendering. Unfortunately, post-SSR, React still generates unnecessary CSS rules that are not utiliz ...

What steps can I take to ensure that an image does not exceed the size of its parent tag?

Is there a way to ensure that items placed in a container do not exceed the boundaries of the container? I am trying to use my logo as the home button, but when I set the image height and width to 100%, it becomes larger than the nav bar. The CSS for the n ...

Step-by-step guide on how to configure the URL path in an AJAX function call

How can I dynamically set the URL path in an AJAX function call when clicking on a page so that the page name is included in the URL? For example, if I click on a particular page (let's say the "ask" page on Stack Overflow), the URL should look like: ...

Hover Effect for Instagram Feed (Web Application)

Recently, I created an app using the Instagram API to bring Instagram images into a webapp. As part of this project, I have been diving into CSS to implement a rollover effect where a heart icon appears when users hover over an image. This heart will event ...

Angular: Intercept Drag and Drop Actions

I am utilizing angular-ui to create a sortable list using "drag and drop" functionality, and it is functioning perfectly. Here is an example of how it works: index.html <ul ui-sortable ng-model="list"> <li ng-repeat="item in list" class="it ...

Adjusting the width of the Bootstrap input group-prepend/addon

I am encountering difficulties with ensuring that all prepend add-ons have the same width. The issue arises when using Font Awesome icons, as each prepend is sized according to its specific icon. I came across a similar thread from approximately one year a ...

Bring the element into view by scrolling horizontally

I am facing a challenge with a list of floated left divs inside another div. This inner block of divs can be hovered over to move it left and right. Each inner div, known as 'events', has class names that include a specific year. Additionally, t ...

Using CSS :hover for elements with dual classes only

Is there a way to make the CSS :hover selector work only when two different classes are attached to a div? I have tried a couple of methods, but they eliminate the hover effect. For example: .accordionButton .cyan:hover{ color: cyan; } I cannot s ...

jQuery show/hide function malfunctioning

Currently, I am attempting to create a basic show/hide interaction for a div using jQuery. The goal is to make the artists-home div vanish and be replaced by the .ken-gallery when the .artist-ken is clicked. Here is my current code, although it is not fun ...

The term "Highcharts does not exist"

I'm encountering an issue with my code: <html> <head> <title><%=sAtaskaitaTitle%></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name=vs_targetSchem ...

The lobster custom font is malfunctioning in Internet Explorer

I am trying to use the unique font called lobster. After downloading the lobster.woff2 file, I stored it in the font folder. In my custom CSS, I added the following: @font-face { font-family: 'Lobster'; font-style: normal; font-weight: 40 ...

Adjust the width of the div according to the space available from its neighboring div

Is there a way in Bootstrap to have two divs on the same row, where if one is removed, the remaining div takes up the full width? <div class="row"> <div class="col-sm-6" style="background-color:lavender;">Div1</div> <div class ...

Data not being properly set in the form

Check out this chunk of HTML code: <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"> </script> <script> function getCords(){ ...

Is it possible to close the menu by clicking outside a div or letting it disappear on mouseout after a set period of time?

When visiting a website, you may notice menus that display sub-menus when hovered over. These menus and sub-menus are created using div elements, with the sub-menus hidden initially using style.display = none; The issue arises when a sub-menu is opened an ...

Internet Explorer having trouble with onload function

Here is a snippet of code that I am working with: <html> <head> <style> #visibilitycontent{ visibility:hidden; } </style> </head> <body onload="visibilitychange()"> <div id="header"> This is the h ...

Executing the .click() function of jQuery within a loop

These specific elements are scattered throughout my HTML code <input id="1" type="button" value="1" > and then there's this one <input type="text" name="answer" id="answer"> In my JavaScript, I've defined a function sum =(eve)=&g ...

The interaction of flex-box in the presence of absolute positioning

Hey everyone, I need some help understanding why the flexbox is behaving oddly in this code snippet. 1. <!DOCTYPE html> <html> <head> <style> body{ position: relative; } .container { ...