Changing the Size of React Bootstrap Cards to Fit Your Grid Layout with Custom CSS

I am facing an issue with the varying sizes of react-bootstrap cards within a grid display. Check out the problem I am encountering:

https://i.sstatic.net/szHjI.png

I need the size of Over Under 0.5 card to be different from the one for Match Winner, as there are only 2 selections in the former compared to 3 in the latter. However, I am unsure how to adjust this using CSS. The sizing issue is affecting other cards as well. Below is my React component for a Market, which represents an individual card:

const Market = ({ marketName, selections }) => {
  return (
    <Card className="market-wrapper">
      <Card.Header className="market-header">{marketName}</Card.Header>
      <Table>
        <tbody>
          {selections.map((selection) => (
            <tr key={selection.id}>
              <td>{selection.name}</td>
              <td>{selection.price.toFixed(2)}</td>
            </tr>
          ))}
        </tbody>
      </Table>
    </Card>
  );
};

All these cards are contained within a larger card with the className markets-container. Here's the corresponding CSS:

.market-header {
  color: #fff;
  background-color: #44494f;
  padding: 2.5px 15px;
  border-bottom: solid 2px #c8ceae;
}

.market-wrapper {
  margin: 10px 10px 10px 10px
}
.markets-container {
  margin: 10px 0 0 0;
  min-height: 400px;
  max-height: 400px;
  overflow: auto;
  display: grid;
  grid-template-columns: auto auto;
}

Answer №1

The reason behind this occurrence is that each cell within the grid adjusts its height to fill any remaining empty space. To avoid this issue, it is recommended to enclose every cell with a div tag.

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

Avoid reloading the menu in order to update the page using Jquery-Ajax

I am currently working on a function to reload the page without affecting our menu, which is an accordion. The goal is to refresh the page while keeping the menu in the same state. Below are the jQuery functions I am using to handle the page reload and en ...

Creating a Dual Linear Gradient Background with Tailwind: Step-by-Step Guide

Can you use two linear backgrounds on a single element in Tailwind CSS? I found this CSS code that seems to achieve it: background-image: linear-gradient(to right, #f8fafb 50%, #161616 50%), linear-gradient(to right, #161616 50%, #f8fafb 50%); I att ...

What methods can be used to dynamically pan the entire picture in a programmatic way?

I have a massive div measuring 11500x11500 pixels that contains 400 images, causing it to overflow the viewport. My goal is to programmatically pan across the entire div. I'm aiming to create an animation that pans the entire div from top to bottom, ...

What is the equivalent of getElementById in .ts when working with tags in .js?

Looking to incorporate Electron, Preload, Renderer with ReactJS and TypeScript into my project. <index.html> <body> <div id="root" /> <script src='./renderer.js'/> </body> <index.ts> const root = Re ...

Change every occurrence of span class red to be a strike tag

I'm attempting to replace all span tags with the red class and their content with a strike tag. However, I've encountered an issue where it doesn't seem to be replacing the specific span tags as expected. Below is the code snippet: let s ...

What is the best way to trigger an event in a React component upon key press?

I am seeking guidance on enabling a specific action or function to be triggered upon pressing a particular key within a React component. Is there a way to make this customizable for various keys? Disclaimer: This question is self-posed in order to offer ...

The updating of Angular 2 CLI variables does not occur

As a complete newcomer to Angular 2, I recently attempted to start my first project using the Angular CLI. Unfortunately, I encountered some issues. It seems that the variables in my views are not updating as expected. I followed the typical steps: ng n ...

The color of the ellipsis value does not match properly

In my table, I have lines that end with 3 dots '...' when the text overflows. To achieve this, I used the ellipsis value of the text-overflow property. While this works well and the '...' are displayed when resizing the window, I encoun ...

The page is being enhanced with FontAwesome Styles through React rendering

I have managed to successfully incorporate various FontAwesome icons into my React App. However, I am facing an issue where the raw CSS styles from FontAwesome are also being rendered at the top of my page. Upon inspecting my page, I noticed a style elemen ...

Content Blocks with Added Cushioning

I am striving for the cleanest code possible. Can an article and an aside have padding, margins, etc? I have been struggling to achieve this. I find myself having to add a div with a class that accepts padding. article { width:463px; float:left; ...

Apply a class styling when its parent element also has a specific class

Is there a way to target a specific group of elements when the parent class changes? For example, if the parent class is alertStateTrue or alertStateFalse. <div id="parent" class="alertStateTrue"> <div class="childAlertStateTrue"></div ...

What is the reason behind child state resolve functions being executed prior to the parent state promises being resolved?

I am currently utilizing ui-router version 0.2.13. According to this page: All resolves on one state will be resolved before moving on to the next state, even if they aren't injected into that child Additionally, all resolves for all the states ...

Exploring the Bookmarking Capabilities of Firefox

Is there a way to access the users' bookmarks using Firefox API and javascript? Appreciate any help, Bruno ...

Ways to eliminate undesired margin

I am struggling with formatting an HTML list into columns and I can't seem to remove the space between each column. It's frustrating because I want the list to display like rows, without any spacing or at least the ability to control the size of ...

Stop html text from overflowing container

I'm facing an issue with a Bootstrap container where the text inside is overflowing and not aligning properly. How can I ensure that the text stays within the container and doesn't cross over, instead just aligning at the bottom of the upper text ...

How to use a function as the redirectTo parameter in Angular 2+ routing

In my Angular application, I have set up the following route configuration: { path: ParentComponent.path, component: ParentComponent, canActivate: [AuthGuard], children: [ { path: '', pathMatch: 'full', re ...

Verify role declarations and display components if valid

I am currently developing an application using Angular on the front-end and ASP.NET on the back-end. Within this application, there are two roles: user and admin. I have implemented a navigation bar with several buttons that I need to hide based on the use ...

What is the best way to create a clickable background for a modal window?

I am looking to add a chatbox feature to my website and have been utilizing Bootstrap Modal for this purpose. My goal is to keep the modal open even when the user clicks outside of it, while still allowing them to interact with the background of the websi ...

"Utilizing Bootstrap to position the right column at the top on a mobile platform

I am in need of assistance with getting the correct div to display on top when viewed on a mobile device using Bootstrap. The issue is discussed and resolved in this particular discussion. To clarify, I would like my desktop layout to appear as follows: A ...

What are the steps to lift non-React statics using TypeScript and styled-components?

In my code, I have defined three static properties (Header, Body, and Footer) for a Dialog component. However, when I wrap the Dialog component in styled-components, TypeScript throws an error. The error message states: Property 'Header' does no ...