Warm tip: This article is reproduced from serverfault.com, please click

Can you help me to arrange some cards in a web page with Bootstrap 4?

发布于 2020-11-28 15:45:52

I need to arrange some cards, in a web page with Boostrap 4. Can you help me?

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>


<div class="row">
    <div class="col-md-12">
        <div class="row">
            <div class=" col-xl-3 col-lg-6 "><div class="card shadow-sm mb-0  bg-primary">
                card 01
            </div>
        </div>
        <div class=" col-xl-3 col-lg-4 ">
        <div class=" col-xl-3 col-lg-6 "><div class="card shadow-sm mb-0  bg-primary">
    card 01
    </div>
    <div class=" col-xl-3 col-lg-4 ">
        <div class=" col-xl-3 col-lg-6 "><div class="card shadow-sm mb-0  bg-primary">
            card 03
        </div>
        <div class=" col-xl-3 col-lg-4 ">
            <div class=" col-xl-3 col-lg-6 "><div class="card shadow-sm mb-0  bg-primary">
                card 04
            </div>
        </div>
    </div>
</div>

I'm Tried to make bootstrap 4 card like a below image , but my card is not perfect, any idea for how to do correctly this one?

My code:

<div class="row">
    <div class="col-md-12  ">
        <div class="row">
            <div class=" col-xl-3 col-lg-6 "><div class="card shadow-sm mb-0  bg-primary">
                card 01
            </div>
        </div>
        <div class=" col-xl-3 col-lg-4 ">
            <div class=" col-xl-3 col-lg-6 "><div class="card shadow-sm mb-0  bg-primary">
                card 01
            </div>
        </div>
    </div>
</div>

enter image description here

Questioner
core114
Viewed
0
Raeesh Alam 2020-12-03 19:05:21

You can try as below snippet in Bootstrap-v4.

[Check on Full Page]

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">

<div class="container py-3">
  <div class="row">
    <div class="col-sm-12 col-md-4 col-lg-3 py-3">
      <div class="card text-white bg-primary h-100 rounded-0 shadow-sm">
        <div class="card-body">
          <h5 class="card-title">Primary card title</h5>
          <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
        </div>
      </div>
    </div>
    <div class="col-sm-12 col-md-8 col-lg-9">
      <div class="row">
        <div class="col-sm-6 col-lg-4  py-3">
          <div class="card text-white bg-primary rounded-0 shadow-sm">
            <div class="card-body">
              <h5 class="card-title">Primary card title</h5>
              <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
            </div>
          </div>
        </div>
        <div class="col-sm-6 col-lg-4 py-3">
          <div class="card text-white bg-primary rounded-0 shadow-sm">
            <div class="card-body">
              <h5 class="card-title">Primary card title</h5>
              <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
            </div>
          </div>
        </div>
        <div class="col-sm-6 col-lg-4 py-3">
          <div class="card text-white bg-primary rounded-0 shadow-sm">
            <div class="card-body">
              <h5 class="card-title">Primary card title</h5>
              <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
            </div>
          </div>
        </div>
        <div class="col-sm-6 col-lg-4 py-3">
          <div class="card text-white bg-primary rounded-0 shadow-sm">
            <div class="card-body">
              <h5 class="card-title">Primary card title</h5>
              <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
            </div>
          </div>
        </div>
        <div class="col-sm-6 col-lg-4 py-3">
          <div class="card text-white bg-primary rounded-0 shadow-sm">
            <div class="card-body">
              <h5 class="card-title">Primary card title</h5>
              <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
            </div>
          </div>
        </div>
        <div class="col-sm-6 col-lg-4 py-3">
          <div class="card text-white bg-primary rounded-0 shadow-sm">
            <div class="card-body">
              <h5 class="card-title">Primary card title</h5>
              <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>