Arranging Bootstrap 4 cards in a card deck formation

I am currently utilizing reactstrap to configure cards for a particular view. However, I am facing an issue where the last two cards do not have images in the header and I need them to be stacked. My attempted solution was to add a <Col></Col>, but this resulted in messing up the padding. Is there a more effective way to achieve this without compromising the design? It's important to note that Reactstrap is built on BootStrap 4.

Here is a visual representation of my current setup:

Below is the code snippet for all five cards:

<Container fluid="true">
  <CardDeck>
    <Card>
      <CardImg className="cardImg" top width="25%" src={custImersion} alt="support immersion program" />
      <CardHeader tag="h3">Connect with Customers</CardHeader>
      <CardBody>
        <CardTitle><NavLink to="/ConnCust">Moneyball</NavLink></CardTitle>
        <CardText>Learn from your customers.</CardText>
        <CardTitle>Immerse</CardTitle>
        <CardText>Go onsite with customers.</CardText>
        <Button color="primary"><NavLink to="/supportImmersion">more</NavLink></Button>
      </CardBody>
    </Card>
    <Card>
      <CardImg className="cardImg" top width="25%" src={suppImmersion} alt="customer immersion program" />
      <CardHeader tag="h3">Connect with Support</CardHeader>
      <CardBody>
      <CardTitle>Support Immersion</CardTitle>
        <CardText>Embed onsite with your CSS team.</CardText>
      <CardTitle>Support Queue Enablement</CardTitle>
        <CardText>Remotely empower your CSS team.</CardText>
        <Button color="primary"><NavLink to="/customerImmersion">more</NavLink></Button>
      </CardBody>
    </Card>
    <Card>
      <CardImg className="cardImg" top width="25%" src={Mb} alt="moneyball program" />
      <CardHeader tag="h3">Get Training</CardHeader>
      <CardBody>
        <CardTitle>Online Training</CardTitle>
        <CardText>Moneyball is hypothesis-driven learning from customer data through rapid experimentations. Each step is applied iteratively through the 4 phases of problem discovery, solution design, service delivery, and driving business.</CardText>
        <CardTitle>Classroom</CardTitle>
        <CardText>There are two ways to learn on the Moneyball methodology – online course or an immersive classroom training. Click to learn more.</CardText>
        <Button color="primary"><NavLink to="/learnMB">more</NavLink></Button>
      </CardBody>
    </Card>
    <Col>
      <Card>
        <CardHeader tag="h3">Tools & Resources</CardHeader>
        <CardBody>
          <CardTitle>Moneyball</CardTitle>
          <CardText>
            <li>Resource 1</li>
            <li>Resource 2</li>
            <li>Resource 3</li>
          </CardText>
          <Button color="primary"><NavLink to="/learnMB">more</NavLink></Button>
        </CardBody>
      </Card>
      <Card>
      <CardHeader tag="h3">Events & Links</CardHeader>
        <CardBody>
          <CardTitle>Moneyball</CardTitle>
          <CardText>
            <ul>
              <li>Events 1</li>
              <li>Event 2</li>
              <li>Event 3</li>
            </ul>
          </CardText>
          <Button color="primary"><NavLink to="/learnMB">more</NavLink></Button>
        </CardBody>
      </Card>
    </Col>
  </CardDeck>
</Container>

Answer №1

Arranging the card-deck cards in a single column can be quite challenging. One method involves utilizing a hack to wrap the last two cards and then adjusting the padding and position of the cards accordingly, as demonstrated here.

<div class="col d-flex flex-column px-0">..</div>

Alternatively, it might be more effective to simply place the cards within a grid layout...

https://www.codeply.com/go/kR47vMqdHm

<div class="container">
    <div class="row">
        <div class="col-4">
            <div class="card mb-4">
                <img class="card-img-top img-fluid" src="//placehold.it/500x280" alt="Card image cap">
                <div class="card-block">
                    <h4 class="card-title">1 Card title</h4>
                    <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                    <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                </div>
            </div>
        </div>
        <div class="col-4">
            <div class="card mb-4">
                <img class="card-img-top img-fluid" src="//placehold.it/500x380" alt="Card image cap">
                <div class="card-block">
                    <h4 class="card-title">2 Card title</h4>
                    <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                    <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                </div>
            </div>
        </div>
        <div class="col-4">
            <div class="card mb-4">
                <div class="card-block">
                    <h4 class="card-title">3 Card title</h4>
                    <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                    <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                </div>
            </div>
            <div class="card mb-4">
                <div class="card-block">
                    <h4 class="card-title">4 Card title</h4>
                    <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                    <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                </div>
            </div>
        </div>
    </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

How can I prevent IE 9 from allowing users to resize the input text field and remove the border around it?

I'm trying to add a text input field inside a contenteditable div in IE 9, but the input field ends up being resizable and has a border around it. I've attempted to fix this using CSS, but unfortunately, it's not working as expected. Here is ...

Make sure that bootstrap is set to disregard the taller column heights

Is there a method to manipulate Bootstrap so that the first column of the second row is positioned just below the height of its corresponding column in the previous row? At present, each row adjusts its height based on the tallest column. <div class=&q ...

Unnecessary Extra Spacing in Every <li> Tag

After searching thoroughly, the problem still remains elusive. Space seems to be mysteriously added to each list item within this code block. My suspicion lies with the for loop as it consistently adds a fixed amount of space. https://i.sstatic.net/0giRG. ...

Django - issue with table display showing empty row due to query set

In my project, I have two models: one named Season and the other one named Game: # Season class Season(models.Model): teams = models.ManyToManyField('Team', related_name='season_teams', blank=True) current = models.BooleanF ...

Exploring Knockout's foreach binding with nested table structures

I find myself in a rather unique situation and I am looking to see if knockout js can help me solve it. Here is the setup: Order = function() { var self = this; self.Name = 'default'; } Customer = function() { var self = this; ...

Maintaining the footer and bottom section of the webpage

I am facing an issue with the footer on my website . I want the footer to always stay at the bottom of the page, even when I dynamically inject HTML code using JavaScript. The footer displays correctly on the main page , but it does not work as intended on ...

Linking to a different webpage within HTML code

If I have two separate HTML files named footer.html and main.html. The footer file includes a link to the top of a page like this: <!-- footer.html --> <!doctype html> <html lang="en"> <head></head> <body> <footer ...

A method for utilizing wildcards in conjunction with the .load function

Currently, I am utilizing jquery, jquery mobile, js, html, and css within Phonegap to develop my android/ios application. However, my understanding of js & jquery is somewhat limited. In my index.html file, I use .load to load other html files into s ...

I've been tinkering with trying to improve the responsiveness of this component in CSS, but I'm struggling to make significant progress

Having trouble with the container named mst missing the bg class. Wondering if it's related to margin, padding, or a display property that I may have overlooked. Also, seeking advice on creating a more mobile-friendly component. Any help is appreciate ...

CSS grid: guarantee that all dynamic rows maintain a uniform size throughout

I'm facing a unique scenario here. I'm attempting to utilize CSS grid to display content side by side. The challenge is that one side of the content needs to have dynamic height while the other side should remain fixed. Here's an example: ...

Steps to customize the color of the img-thumbnail in Bootstrap 4 on an HTML webpage

After running my code, I noticed the following: Is there a way to change the image border color to black? If so, how can I achieve that? <section style="background: #dfe6e9;" class="p-3"> <div class="container"> <div class="row"> ...

Personalized Firefox Scrollbar - Rounded Corners

I have successfully customized the default CSS of browser scrollbars for Chrome and Edge, but I am facing issues with Firefox. Is there a way to sync the scrollbar styling in Firefox with Chrome and Edge? Currently, I am unable to apply border radius to th ...

Adjust the dimensions of a div element based on the screen size

I'm struggling with adjusting the size of a div responsively based on the surrounding divs. My layout includes buttons on both sides of the page and text in the middle that varies from 0 to 140 characters. What I aim to achieve is for the buttons to ...

Issues with Jquery show and hide functionality within a list element

My menu items are displayed using show and hide functions, sliding up and down on hover. The issue I am facing is that when a list item expands, the overall background of the menu also expands. However, when it contracts, the background also contracts. If ...

The function is unable to locate the variable

After I made some changes to the CSS of my game, I started encountering a variable error every time I clicked a button that called a function. The error message says it cannot find the variable. Even though I removed the CSS, the game is still not functio ...

The slides on SlickJS are initially loaded in a vertical alignment, but once the arrows are interacted with,

I've put together a demonstration that highlights the issue I'm facing. Upon visiting the contact section, you'll notice that all the slickJS slides are stacked vertically initially, but once you interact with them by clicking on the arrow o ...

Click on the submenu to expand it, then simply select the desired option to navigate

I have created a toggle menu that displays a list of child elements when clicked, and hides them if clicked again. However, when a child element is clicked, I want it to navigate to the corresponding page. I am having trouble getting this functionality to ...

Having trouble with this code// Does anyone know how to make the div slide in line with other divs when hovering over it?

After spending countless hours analyzing and trying various solutions, I have come to the realization that I need to seek help with my code. The task at hand is proving to be incredibly frustrating, and I have exhausted all other options before resorting t ...

What is the best way to trigger an event function again once a specific condition has been satisfied?

I'm currently working on a project where I need a sidebar to scroll at a slower rate until it reaches a specific point, and then stop scrolling once that point is reached. Below is the jQuery code I've been using: $(window).on("scroll", function ...

CSS3 columns are not behaving as expected, causing elements to be oddly positioned and not filling the width correctly

Exploring the column rule in CSS for a Pinterest-inspired layout has been a bit confusing. The results are not turning out as expected, and I suspect there might be an error in my approach. One issue I've encountered is that when the number of child ...