Bootstrap 4-卡座和不同大小

我要显示尊重Boostrap网格的高度相同但大小不同的卡片。

If I take the example of card-deck : https://jsfiddle.net/sb7t5y3x/, I just want for example the first card to be col-6 sized, for me the most elegant way should be :

<div class="card col-6"> .... </div>

But it doesn't work since .card-deck > .card applies a flex 1.

所以我试图将我的卡片包装在col中:

<div class="col-6">
    <div class="card"> ... </div>
</div>

But col have paddings, and card have margin, so I have 2 margins applied (see https://jsfiddle.net/applyss/vcgkujxp/, spaces are not regular)

是否有一种简单的标准方法来在网格系统中保持相同高度的卡?

评论
拜托说爱我
拜托说爱我

这是一个简单的示例,显然很奇怪,但是所有div的高度都与您想要的相同。

.row {
  background: #f8f9fa;
  margin-top: 20px;
}

.col {
  border: solid 1px #6c757d;
  padding: 10px;
}
  <script type="text/javascript" src="/js/lib/dummy.js"></script>

    <link rel="stylesheet" type="text/css" href="/css/result-light.css">

      <script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.slim.js"></script>
      <link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css">
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.js"></script>
      <script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.js"></script>
      <link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css">

<div class="container pt-3">
<div class="card-deck">
  <div class="col-md-8  d-flex align-items-stretch">
  <div class="card">
    <div class="card-body">
      <h5 class="card-title">Card title</h5>
      <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="card">
    <div class="card-body">
      <h5 class="card-title">Card title</h5>
      <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
    </div>
  </div>
  <div class="card col-6">
    <div class="card-body">
      <h5 class="card-title">Card title</h5>
      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
    </div>
  </div>
</div>
</div>
点赞
评论