Using Bootstrap's card component, design a grid layout for your website

I am attempting to construct a grid using the Bootstrap 4 card component. After reviewing the documentation and utilizing the card-deck feature, I aim to have each row consist of two columns with the behavior similar to col-12 col-md-6. Additionally, the second column needs to be split into two rows, each containing a horizontal card. Below is the snippet of code I currently have:

<div class="container">
    <div class="row">
        <div class="card-deck">
            <div class="card">
                <img
                    class="card-img-top"
                    src$="{{getArticleImage2(article1)}}"
                />
                <div class="card-body py-2">
                    <div class="d-flex justify-content-start align-items-center mb-2">
                        <img class="icon-sm mr-2 img-fluid" src={{getFavIcon(article1)}}>
                        <a class="card-link medium-text" target="_blank" href$="https://{{getSources(article1)}}">
                            {{getSources(article1)}}
                        </a>
                    </div>
                    <p class="card-text article-headline medium-text">
                        {{article1.schema:headline}}
                    </p>
                </div>
            </div>

            <div class="card">
                <div class="row no-gutters">
                    <div class="col-md-5">
                        <img
                            class="card-img"
                            src$="{{getArticleImage2(article2)}}"
                        />
                    </div>
                    <div class="col-md-7">
                        <div class="card-body p-2">
                            <div class="d-flex justify-content-start align-items-center mb-2">
                                <img class="icon-sm mr-2 img-fluid" src={{getFavIcon(article2)}}>
                                <a class="card-link medium-text" target="_blank" href$="https://{{getSources(article2)}}">
                                    {{getSources(article2)}}
                                </a>
                            </div>
                            <p class="card-text article-headline medium-text">
                                {{article2.schema:headline}}
                            </p>
                        </div>
                    </div>
                </div>                        
            </div>

            <div class="card">
                <div class="row no-gutters">
                    <div class="col-md-5">
                        <img
                            class="card-img"
                            src$="{{getArticleImage2(article2)}}"
                        />
                    </div>
                    <div class="col-md-7">
                        <div class="card-body p-2">
                            <div class="d-flex justify-content-start align-items-center mb-2">
                                <img class="icon-sm mr-2 img-fluid" src={{getFavIcon(article3)}}>
                                <a class="card-link medium-text" target="_blank" href$="https://{{getSources(article3)}}">
                                    {{getSources(article3)}}
                                </a>
                            </div>
                            <p class="card-text article-headline medium-text">
                                {{article3.schema:headline}}
                            </p>
                        </div>
                    </div>
                </div>                        
            </div>
        </div>
    </div>
</div>

The issue I am encountering is that instead of having only two columns, I'm getting three. The last two cards are being displayed horizontally but they should be stacked one below the other. You can view the code snippet here. How can I resolve this?

Answer №1

When you insert a div with the class card-columns like this:

<div class="card-deck">
            <div class="card-columns">
                <div class="card">
                    <img
                        class="card-img-top"
                        src=""
                    />
                    <div class="card-body py-2">
                       //.................

You will see two columns, one displaying a card vertically and the other containing two cards side by side. https://i.sstatic.net/bNgrN.png

Don't forget to check out the last section of the documentation as it may help you specify how many cards you want in each column. https://getbootstrap.com/docs/4.3/components/card/

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

Retrieving webpage information in XML structure with CURL

My goal is to retrieve data in both XML and HTML formats using the curl command. curl --data "<xml>" --header "Content-Type: xml" http://example.com curl --data "<html>" --header "Content-Type: html" http://example.com In both cases, I r ...

Crushing jQuery's Sortable/Droppable

Having a little issue here. I want to be able to toggle the sortable plugin's behavior by clicking a button - basically switching between sort mode and view mode. I've attempted to achieve this with the following code: function enterSortMode(){ ...

Troubleshooting the Ineffectiveness of AJAX in Image Map Coordinate Hover Feature

I am currently facing an issue with setting up an image map with ajax hover functionality to retrieve information from the database table major_occurrence. Unfortunately, the ajax call does not seem to be working at all. The hover element is clickable and ...

Issue with custom select functionality on Internet Explorer 9

Having some issues with a select element in IE9. The links that should open the wiki page are not functioning properly only on IE9, and there is also an issue with the hover effect - the icon gets overridden by the background color when hovering over help ...

- Convert text style and include bullet points: • Alter

Is there a way to convert the script from a Mail_Object to HTML in order to properly format lines 3 and 4 into bullet points, as well as change the font on line 5? I have no knowledge of HTML. The code below functions but does not apply any formatting or ...

JQuery .click Event doesn't center elements even with transform-origin adjustment

In the JSfiddle provided below, you can see that after a click event occurs, two span (block) elements rotate 45deg to form an "X". However, both elements are slightly shifted left, creating an off-center "X" relative to the parent's true center-origi ...

Dynamically taking input in Vue JS while using v-for loop

Hey there! I'm trying to get input in this specific manner: itemPrices: [{regionId: "A", price: "200"},{regionId: "B", price: "100"}] Whenever the user clicks on the add button, new input fields should be added ...

Changing the height of one Div based on another Div's height

I currently have a display of four divs positioned side by side. I am seeking a solution to ensure that the height of each div remains consistent, and should adjust accordingly if one of them increases in size due to added text content. For reference, ple ...

"VS Code's word wrap feature is beneficial for wrapping long lines of text and code, preventing them from breaking and ensuring they are

text not aligning properly and causing unnecessary line breaks insert image here I attempted to toggle the word wrap feature, installed the Rewrap plugin, and played around with vscode settings ...

When I try to host my Jekyll site on GitHub Pages using my custom domain, the CSS doesn't seem to be rendering at all

Everything looks perfect when I test my site on local host, but once I push it to my GitHub repo, only the HTML appears with no CSS or JavaScript. I've attempted changing my URL in the config.yml file to https://chanvrequebec.com and modifying href="/ ...

Shift the "Login link" to the right side of the Bootstrap navbar

Currently working on a Django website and incorporating Bootstrap/CSS/HTML to enhance the design. I've set up a navbar menu and want the login tab on the right side. However, despite my attempts, I'm not achieving the desired outcome: The HTML ...

Discover the method for measuring the size of a dynamically generated list

I'm currently working on a chat box that displays messages as a list. One issue I'm facing is that when I click on the start chat button, the chat box opens but the length of the list always remains zero. How can I resolve this problem? $(docu ...

Guide to leveraging clsx within nested components in React

I am currently using clsx within a React application and encountering an issue with how to utilize it when dealing with mappings and nested components. For instance: return ( <div> <button onClick={doSomething}>{isOpened ? <Component ...

JavaScript for Verifying Phone Numbers

After extensive research and tutorials, I am still unable to figure out what is going wrong with my work. I have a button that looks like this: Despite Stack Overflow causing some trouble for me, please ignore the missing class as it is there. This is no ...

Enhance and Modify feature using Javascript

I'm facing two issues with my product information form. Firstly, after I submit the data, I want the input fields to be cleared automatically. Secondly, the edit function doesn't seem to work at all. I'm quite stuck on how to resolve these p ...

After a CSS animation, the Div element disappears from view

I recently implemented a CSS3 delayed animation on page load. Everything was working smoothly until I noticed that after the animation finishes, the DIV reverts back to visibility: hidden. .content-left { margin-left: 100px; margin-top: 32px; ...

Steps for aligning a table in the middle of a webpage

Can someone help me align my table to the center of the webpage? I have tried using align="right" and "center" but neither seem to be working. Any tips on how to position the table correctly? <table style="table-layout:fixed;" align="right" cellspaci ...

What is the best way to create an arrow that tracks the browser window, but only goes as far as the end of its designated container

Currently, I am facing a challenge in implementing a scroll down arrow. While this is typically a simple task, it has proven to be a bit more complex this time around. The complexity arises from the fact that my customer desires a homepage with an image of ...

Easily move elements using a jQuery click animation

Having trouble animating a div's top position by -130px to move it off screen? Can't figure out why it's not working? I'm fairly new to jQuery/Javascript. I have a button/hyperlink with the ID #NavShrink. When clicked, I want the div # ...

Centering loaders within elements of an unordered list

I am working on a navbar that uses Bootstrap 3 and AngularJS. Within this navbar, I have an unordered list with li elements. Below is a snippet of my navbar: https://i.stack.imgur.com/o75Lp.png This is the code for my navbar: <div class="navbar-head ...