具有动态标题和固定主体的Bootstrap 4卡

时间:2018-11-23 09:57:45

标签: css twitter-bootstrap

我正在使用引导4卡:

<div class="card" style="height:"500px;width:100px">
  <div class="card-body">
    <div class="top-portion">
        This portion can span from one to many lines.
    </div>
    <div class="content" style="overflow-y">
        ....
        ....
    </div>
  </div>
</div>

我需要“ .content” div来占据剩余的垂直空间,并且在需要时可以滚动。我知道应该在样式中加上“ max-height:...”。

但是,问题在于我不知道要输入的确切值,因为“ .top-portion”部分的高度不同。

1 个答案:

答案 0 :(得分:0)

    <div class="card" style="height:500px; width:100px;overflow: hidden;">
        <div class="card-body d-flex flex-column">
          <div class="top-portion mb-auto">
              This portion can span from one to many lines.
          </div>
          <div class="content" style="overflow-y:auto;max-height: 200px;">
              Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
          </div>
        </div>
      </div>

将此代码用于您的卡。并且“顶部”高度不会干扰内容。我已经使用“ mb-auto”,这意味着margin-bottom:auto;如果要将内容区域放在卡的底部。