Design cards in a particular sequence using either bootstrap or CSS

I am currently developing a blog website and I need assistance with arranging the cards in this specific order: https://i.sstatic.net/Ffpcb.png

Despite my efforts using Bootstrap, I am unable to achieve the desired layout. Here is the code I have so far:

<div class="row">
<div class="col-md-4"> <Card>
        <img className="card-img-top" src='{activity.image[0].url}' alt=""/>
     
      {/* <Link to={`/product/${product.name}`}>  */}
          <Card.Body>
              {/* <Link to={`/product/${activity.id}`}>  */}
              <Card.Title>Title</Card.Title>
              {/* </Link> */}
             
              <Card.Text>$Price</Card.Text> 
              <Button className='btn-gallery'>See Blog</Button>
          </Card.Body>
          
  </Card>
    </div>
<div class="col-md-4 offset-md-4">.col-md-4 .offset-md-4</div>
</div>
<div class="row">
<div class="col-md-3 offset-md-3">.col-md-3 .offset-md-3</div>
<div class="col-md-3 offset-md-3">.col-md-3 .offset-md-3</div>
</div>
<div class="row">
<div class="col-md-6 offset-md-3">.col-md-6 .offset-md-3</div>
</div>

Is there anyone who can guide me on how to structure the cards just like shown in the provided screenshot?

Answer №1

Hopefully the code below will provide you with the solution you are seeking. I have utilized a row-column structure and Bootstrap cards for this purpose.

In the layout, there is a parent row containing three columns. Among these columns, I have set one to be 100% height, and for the middle column, I have enclosed it in another row with two additional columns.

The responsiveness has been managed with row-cols-md-4 for larger devices and row-cols-1 for smaller devices.

Please check out this link for a better understanding: https://jsfiddle.net/yudizsolutions/ogxaecu2/

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6e0c01011a1d1a1c0f1e2e5b405c405d">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
  <title>Document</title>
</head>

<body>
  <section class="card-section">
    <div class="container p-3 bg-secondary">
      <div class="row row-cols-md-4 row-cols-1 g-5 justify-content-center">
        <div class="col">
          <div class="card h-100">
            <div class="card-body text-center d-flex align-items-center justify-content-center flex-column">
              <img width="100%" height="auto" src="https://fastly.picsum.photos/id/80/3888/2592.jpg?hmac=zD95NwXZ7mGAMj-z4444Elf43I4HJvd7Afm2tloweLw" alt="Image">
              <h2>Some text</h2>
            </div>
          </div>
        </div>
        <div class="col h-100">
          <div class="row row-cols-1 g-5">
            <div class="col">
              <div class="card">
                <div class="card-body text-center d-flex align-items-center justify-content-center flex-column">
                  <img width="100%" height="auto" src="https://fastly.picsum.photos/id/9/5000/3269.jpg?hmac=cZKbaLeduq7rNB8X-bigYO8bvPIWtT-mh8GRXtU3vPc" alt="Image">
                  <h2>Some text</h2>
                </div>
              </div>
            </div>
            <div class="col">
              <div class="card">
                <div class="card-body text-center d-flex align-items-center justify-content-center flex-column">
                  <img width="100%" height="auto" src="https://fastly.picsum.photos/id/13/2500/1667.jpg?hmac=SoX9UoHhN8HyklRA4A3vcCWJMVtiBXUg0W4ljWTor7s" alt="Image">
                  <h2>Some text</h2>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="col">
          <div class="card h-100">
            <div class="card-body text-center d-flex align-items-center justify-content-center flex-column">
              <img width="100%" height="auto" src="https://fastly.picsum.photos/id/20/3670/2462.jpg?hmac=CmQ0ln-k5ZqkdtLvVO23LjVAEabZQx2wOaT4pyeG10I" alt="Image">
              <h2>Some text</h2>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="71131e1e05020503100131445f435f42">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
</body>

</html>

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

The compatibility between Typescript methods and event handlers is lacking

Consider this basic TypeScript script class foo { v: number = 1; public bar() { console.log(this.v); } } var a = new foo(); var b = new foo(); document.getElementById('test').addEventListener("click", a.bar); document.getE ...

Ways to update an angular page using the router without resorting to window.location.reload

I have a specific method for resetting values in a component page. The process involves navigating from the "new-edition" page to the "my-editions" component and then returning to the original location at "new-edition". I am currently using this approach ...

What is the best way to style odd and even divs in CSS?

I am struggling with applying different CSS styles to the odd and even divs in my code. The current implementation I have does not seem to be working as expected. I specifically want the styling to target only the direct children of the div, rather than an ...

Multiple images overlapping each other in a dynamic parallax effect

Despite my fear of receiving down votes, I have been unsuccessful in finding the answer to my question so I will proceed with asking it. I am attempting to replicate a parallax effect similar to the one showcased on this website, particularly the image of ...

Creating dynamic dropdown menus using JSON files in jQuery mobile is a useful technique for enhancing user experience on

I am working with a massive table (8 MBytes) that I need to filter using a small JavaScript application. The process works as follows: Countries Regions Skills I want the user to select one country, one region, and multiple skills as filters. Based on ...

After an Ajax request, the functionality of Javascript/Jquery ceases to work

After successfully submitting a form via ajax for the first time, the subsequent submissions seem to break all javascript functionality on the page. Additionally, the form is unable to submit with ajax again. Below is the code snippet for the ajax call: ...

What is the best way to display the panel during a postback?

I have a group with two radio buttons labeled purchase and expenses. When the purchase radio button is clicked, the panelpurchase will be displayed, and similarly, the panelexpense will show for the expenses radio button. Check out the image of the output ...

How to extract user data from a JWT token using Node.js?

In my MEAN stack authentication application, I am utilizing Node and Angular. After a successful login, I set a JWT token and store it in a session within the controller by assigning the token to config.headers through a service interceptor: var token = j ...

Oops! The system encountered a problem while trying to identify the value `Han` for the property `Script

I'm attempting to extract Chinese characters from a string. According to this particular answer, the following code snippet should work: const nonChinese = /[^\p{Script=Han}]/gimu; const text = "asdP asfasf这些年asfagg 我开源的 几 ...

Positioning custom buttons using CSS and HTML

Need help with centering a button inside a div within a table cell. Is there a way to determine the current size of the hovered-over div and position the button in the middle both vertically and horizontally? https://i.sstatic.net/6NQ9J.jpg I hope you ...

My PHP code keeps prompting me with an "invalid password" message even though I am confident that the password is correct

As part of a project at work, I am creating an intentionally flawed application to showcase common security vulnerabilities. This application is designed to demonstrate improper practices and may even entice those looking to exploit it. We have robust logg ...

Chrome's rendering of CSS flex display shows variations with identical flex items

I am facing an issue with my flex items where some of them are displaying incorrectly in Chrome but fine in Firefox. The problem seems to be with the margin-right of the rectangle span within each flex item, along with the scaling of the text span due to f ...

Check input validations in Vue.js when a field loses focus

So I've created a table with multiple tr elements generated using a v-for loop The code snippet looks like this: <tr v-for="(item, index) in documentItems" :key="item.id" class="border-b border-l border-r border-black text ...

Can you explain the functionality of that snippet of JavaScript code?

Can you figure out the value of r? How does it relate to Boolean operators and objects? var data = {x:123, y:456}; var r = data && data.x || 0; Update: Upon running the code snippet, I noticed that r consistently equals x. However, the reason behind thi ...

Ensuring the consistency of actions through thorough testing

Currently utilizing xstate for the implementation of a login flow. Within my machine, the initialState triggers a Promise, which redirects to a state with an entry action if rejected. I am seeking to properly test the timing of when this action is called. ...

Closing the Bootstrap Dropdown Menu

I have a dropdown menu in my bootstrap project. I am looking for a way to make the menu close when I click on one of the menu items, without refreshing the page. The links function like an ajax request model, ensuring that the page does not reload. <l ...

Interactive window allowing the user to closely examine code

Hey guys, I need your help with something Is there a way (PHP / jQuery) that allows me to zoom in on my code? Similar to how lightbox works for images. I specifically want to zoom in on dynamic code while using Yii's CListView. I'm thinking of ...

Establish height and width parameters for creating a dynamic and adaptable bar chart with recharts

I am currently facing an issue with recharts while trying to implement a BarChart. The setting width={600} and height={300} is causing the Barchart to be fixed in size, rather than responsive. How can I make the BarChart responsive? I attempted using per ...

Node.js Buffer problem: How to tackle it

Encountering an issue with buffers in Node.js The constant buffer is defined as follows: var commands = { BufferOne : new Buffer([0XCA, 0X11, 0X00, 0X00, 0X60, 0X01, 0X00, 0X01, 0X08, 0X07, 0X6D, 0X00, 0X00, 0X00, 0X00, 0 ...

CSS problem with padding and width

Currently, I'm working on a conditional rendering issue where I want to give a div full width but due to padding applied to its parent, it's not expanding to the container's full width. Here is the snippet of the code: import Image from &qu ...