首页 > 解决方案 > What is the Bootstrap card-block class?

问题描述

I don't see the class card-block mentioned in the reference documentation, but I have seen this class used in a few examples. This is the officially reference:

https://getbootstrap.com/docs/4.0/components/card/

And this is an example where the class is used:

https://www.codeply.com/go/pVsGQZVVtG/bootstrap-4-no-gutters-(spacing)

I've seen cards used but what is this card-block class?

Example:

<div class="row">
  <div class="col-3">
    <div class="card">
      <div class="card-block">
        normal
      </div>
    </div>
  </div>
  <div class="col-4">
    <div class="card">
      <div class="card-block">
        normal
      </div>
    </div>
  </div>
  <div class="col">
    <div class="card">
      <div class="card-block">
        normal
      </div>
    </div>
  </div>
</div>

标签: twitter-bootstrap

解决方案


该类card-blockBootstrap 4的Alpha版本中使用,在当前版本中不存在。您可以在链接上阅读该类的文档:card-block on v4-Alpha。那里说:

卡片的组成部分是.card-block. 每当您需要卡片中的填充部分时使用它。

就像我已经提到的,这个类在当前的v4.1.3 版本或其他高级版本中不存在。您可以在下一个示例中使用浏览器检查器工具进行检查,并查看没有与该类相关的CSScard-block样式,但存在与官方文档或类相关的CSS样式,例如示例。card-headercard-body

链接到官方文档cardsBootstrap Cards

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

<div class="container-fluid">

  <div class="card">
    <div class="card-block">
    card-block
    </div>
  </div>
  <br>
  <div class="card">
    <div class="card-header">
      card-header
    </div>
    <div class="card-body">
      card-body
    </div>
  </div>

</div>


推荐阅读