Bootstrap 4卡片组内的相同高度列表组

时间:2018-04-24 12:38:05

标签: html bootstrap-4

我喜欢制作一个带有Bootstrap 4的卡片桌,其中包含内部列表组或卡块(无论哪个部分),这些部分应具有相同的水平高度。

我尝试使用 d-flex flex-column list-groups 。没有任何工作按预期。 为每个部分设置固定高度不是一种选择。

实施例: https://jsfiddle.net/7kvktrh5/

代码:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">

<div class="container py-4">

  <div class="card-deck">

    <div class="card">
      <div class="card-body">
        <h4 class="card-title">Product 1</h4>
        <p class="card-text"></p>
      </div>
      <hr>
      <div class="card-body">
        <p class="card-text">Some description</p>
      </div>
      <hr>
      <div class="card-body">
        <p class="card-text">Price</p>
      </div>
    </div>

    <div class="card">
      <div class="card-body">
        <h4 class="card-title">Product 2</h4>
        <p class="card-text">Some Text</p>
      </div>
      <hr>
      <div class="card-body">
        <p class="card-text">Some description: This card has supporting text belosupporting textporting text belosuppal content.</p>
      </div>
      <hr>
      <div class="card-body">
        <p class="card-text">Price</p>
      </div>
    </div>

    <div class="card">
      <div class="card-body">
        <h4 class="card-title">Product 3</h4>
        <p class="card-text">This is a wider card little bit longer.</p>
      </div>
      <hr>
      <div class="card-body">
        <p class="card-text">Some description: This card textporting text belosuppal content.</p>
      </div>
      <hr>
      <div class="card-body">
        <p class="card-text">Price</p>
      </div>
    </div>
  </div>

1 个答案:

答案 0 :(得分:0)

我希望这是你的解决方案

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">

<div class="container py-4">

  <div class="card-deck">

    <div class="card border-bottom-0 rounded-top" style="border-radius:0;">
      <div class="card-body">
        <h4 class="card-title">Product 1</h4>
        <p class="card-text"></p>
      </div>

    </div>

    <div class="card border-bottom-0 " style="border-radius:0;">
      <div class="card-body">
        <h4 class="card-title">Product 2</h4>
        <p class="card-text">Some Text</p>
      </div>

    </div>

    <div class="card border-bottom-0" style="border-radius:0;">
      <div class="card-body">
        <h4 class="card-title">Product 3</h4>
        <p class="card-text">This is a wider card little bit longer.</p>
      </div>

    </div>
  </div>
  <div class="card-deck">

    <div class="card rounded-0">
      <div class="card-body">
        <h4 class="card-title">Product 1</h4>
        <p class="card-text">Some description: This card has supporting text belosupporting textporting text belosuppal content.</p>
      </div>

    </div>

    <div class="card rounded-0">
      <div class="card-body">
        <h4 class="card-title">Product 2</h4>
        <p class="card-text">Some Text</p>
      </div>

    </div>

    <div class="card rounded-0">
      <div class="card-body">
        <h4 class="card-title">Product 3</h4>
        <p class="card-text">This is a wider card little bit longer.           </p>
      </div>

    </div>
  </div>
  
  <div class="card-deck">

    <div class="card border-top-0 rounded-bottom" style="border-radius:0;">
      <div class="card-body">
        <h4 class="card-title">Product 1</h4>
        <p class="card-text"></p>
      </div>

    </div>

    <div class="card border-top-0 rounded-bottom" style="border-radius:0;">
      <div class="card-body">
        <h4 class="card-title">Product 2</h4>
        <p class="card-text">Some Text</p>
      </div>

    </div>

    <div class="card border-top-0 rounded-bottom" style="border-radius:0;">
      <div class="card-body">
        <h4 class="card-title">Product 3</h4>
        <p class="card-text">This is a wider card little bit longer.           </p>
      </div>

    </div>
  </div>
  </div>