Instructions for making all the cells in a Bootstrap 3 row the same height

I'm currently working on a grid of cards that can be flipped and have varying content. I'm attempting to make the height of cards with less content equal to the card with the most content. However, regardless of where I use height:100%, the smaller cells remain at their original size. I understand that the row naturally has the maximum height, but why can't all child cells inherit this height?

Check out this example: http://www.bootply.com/NnHFEKwrwu

Answer №1

In order to grasp the concept of height, it's important to understand that it will only occupy the specified amount of space that is assigned to it. For example, if a container element has a height of 300px, and a child element within has the CSS property of height:100%, then that child element will adapt to that specific height.

In this scenario, the absence of a specific height declaration on any elements other than height:100% or min-height:100% suggests that the minimum height will always be a fixed value, such as in pixels (px) or em units.

If your goal is to ensure uniform height for all boxes, you can refer to my previous response provided here. The strategy involves identifying a group of elements (marked by XX) and determining the maximum height among them. This determined height is then applied uniformly across all elements in that group.

This approach is commonly used when creating carousels, modals, tooltips, or columns with consistent heights to enhance the overall layout aesthetics.

To implement this in your situation, you would need to iterate through all .card elements, calculate their max-height, and assign it to the entire group. I recommend using the outerHeight() method as it accounts for the total dimensions including border, padding, and margin.

var maxHeightOfCards = $('.card').map(function() {
    return $(this).outerHeight();
}).get();

// Alternatively, you can use $('.card').css('height', Math.max.apply(null, maxHeightOfCards))
$('.card').height(Math.max.apply(null, maxHeightOfCards));

Answer №2

Despite the numerous issues with your code, the answer you seek is surprisingly straightforward:

.row {
  display:table;
}
.row > div {
  display:table-cell;
  float:none;
  height:100%;
}

It really is that simple. Just apply height:100% to the child elements.

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

Using the onClick function to set attributes in React JS

I am currently working with 2 functions: addBookmark() and removeBookmark(). There is a variable called IsBookmarked that can be either true or false. In my JSX code related to bookmarks, it looks like this: {props.singleCompany.IsBookmarked ? ( ...

I'm having trouble figuring out the code for the path in the POST request for my basic login form application

I have built a basic login form application in node.js. Although I can successfully display the login form and input login data, my POST request to capture the login data is not functioning correctly. I am encountering a POST http://localhost:3000/client 4 ...

How can I trigger both the submit event and close a modal when a form is submitted in Angular 2 with Bootstrap?

Within a bootstrap modal, I have implemented a form. Upon the submission of the form by the user, the (submit) event is supposed to trigger addArticle($event) and subsequently, the modal should close. <div class="modal fade"> <div class="modal- ...

Baffled by the intricacies of jQuery

As a newcomer to jQuery, I stumbled upon this code snippet and am curious about its function. It seems like it is replacing an element with the id reveal to a link with the class html5lightbox and id reveal. However, the part that puzzles me is $( '#r ...

Is there a way to verify if a specific combination of keys has been pressed using JavaScript?

Currently, I am creating a software application that requires the integration of custom hotkeys. These hotkeys need to be chosen by the user and stored for future use. For instance, if the user selects CTRL + M, how can I save this combination and trigge ...

Discover the secrets to achieving complete customization of your data table's appearance using the DevExtreme React Grid in conjunction with material-ui

I am facing difficulties in styling the DevExtreme React Grid, which I found from their documentation here. Here is the sample code that I copied from another repository. I have a few questions: How can I have complete control over the styling? I noti ...

I am encountering an issue where my input is moving to the following line after the initial one. What could be

Trying to create a layout I like for this form has been a bit of a struggle. I thought I had something good at first, but after the first row of input, the formatting gets all messed up and I can't figure out what's going wrong. <!DOCTYPE htm ...

React: Struggling to Get Margins Right for Navigation Bar Spacing

I recently tried my hand at following a tutorial for building a React app: React JS Tutorial for Beginners #1 – Build a website using React, Sass, Gulp and Node.js After completing the tutorial, everything seemed to be working smoothly except for one th ...

What is the best way to take control of DOM alterations?

In the project I'm currently working on, the client has a modal box with its display property set to none. Upon clicking the CTA button, it triggers the application of the fadein and fadeout classes. This results in a change from display:none to displ ...

Aligning items in several columns

Setting up a grid layout where the content is centered can be tricky, but I've found a solution that works well. Take a look at the code snippet below: .outer { width: 100%; height: 100px; margin-top: 10px; m ...

Achieving consistent sizing for React-Bootstrap cards: A guide

In my React app, I am utilizing React-bootstrap and specifically the Card & CardGroup components. I need assistance in ensuring that all the cards have the same height. JSX component: <Card style={{flex: 1}} className="card"> ...

The toggle button is having issues functioning properly within a While loop

Is there a way to enable slideToggle for all my queries? Currently, it is only working on the first query. Any suggestions on how to resolve this issue? JS code $(document).ready(function(){ $("#SendCopy").click(function(){ $("#users").slideToggle("s ...

Add small pieces of content to CKEditor

Is there a way to add "atomic" block content into CKEditor? For instance, I would like to add <h1>Test</h1> right after the letter "B" in the sentence <p>A B C</p>. Currently, when using CKEDITOR.currentInstance.insertHtml('&l ...

Float Property for Aligning DIVs

Is there a way to properly align divs like the ones shown below? I tried setting a float left for both div1 and div2, but div3 ended up floating to the top right. How can I avoid this issue? <div1> <div2> How hot is it? ...

Get information from a specific text input after pressing the Enter key, among several text inputs with identical names and IDs

I am facing a challenge where I have multiple text inputs dynamically generated with the same id and name. My goal is to retrieve the data entered in a specific text input whenever a user hits the 'Enter' key in that field. For example, let&apos ...

The NextJS Link component does not seem to be receiving the styles from Tailwindcss

I am currently working on a nextjs frontend project that has tailwindcss integrated. Below is an example of the code I am using: import Link from 'next/link' return( <div> <Link className="text-sm hover:text-gray-600" ...

After submitting in Moodle, the form fails to validate

I have been working on a form that adapts its structure based on the parameter in the URL. If no parameter is provided in the URL, an error message should be shown. Depending on the ID, a database query is executed, and the form is populated with data. Fo ...

PHP: How to create a custom function to convert JSON data to HTML-encoded text

I am faced with a challenge involving an array containing values from a database, some of which include HTML tags. My goal is to output this array in JSON format, so I am utilizing json_encode for that purpose. However, I am encountering an issue when tr ...

The bootstrap datepicker does not display the date range on the calendar

I tried to incorporate a bootstrap datepicker date-range in the code snippet below, but I am encountering an issue where the selected date range is not displaying on the calendar. <!DOCTYPE html> <html> <head> <link rel="stylesheet" ...

Ways to incorporate custom CSS alongside Bootstrap styling

Just starting out with CSS and HTML I've applied some Bootstrap styles to my HTML elements But when you use a bootstrap style, the class is automatically taken over. This means I can't add my own custom CSS styles. Is there any workaround for thi ...