Bootstrap 卡片不像示例中那样显示

新手上路,请多包涵

为什么我的 Bootstrap 卡片看起来很奇怪?在示例中,它们看起来像带有边框和白色填充的卡片,但我的看起来只是没有填充和白色背景的文本。

例如:

Bootstrap 卡片渲染示例

我不知道该代码是否对您有帮助,但它是:

 .container {
  left: 0;
  right: 0;
  bottom: -340px;
  text-align: middle;
  position: absolute;
}
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
  <div class="row">
    <div class="col-md-3">
      <div class="card">
        <img class="card-img-top" src="http://www.themdfactor.com/wp-content/uploads/2015/09/card1.jpg" alt="Card image cap">
        <div class="card-block">
          <h4 class="card-title">This is Card #1</h4>
          <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>
          <a href="http://v4-alpha.getbootstrap.com/components/card/" class="btn btn-primary">Learn More</a>
        </div>
      </div>
    </div>
  </div>
</div>

原文由 flex_ 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 265
2 个回答

它对我来说很好。您必须确保链接的是版本 4 样式表。

 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">

原文由 Rachel S 发布,翻译遵循 CC BY-SA 3.0 许可协议

Bootstrap 4 卡 功能已经从早期的 v4-alpha 版本到 v4-beta 版本进行了额外的更改。但是,Bootstrap 网站上的示例仍然使用旧的类名。卡片仍然呈现,但如果使用旧的类名,填充将丢失。

当前(2017 年 9 月)示例使用 card-body 类 ( CSS ):

 <div class="card" style="width: 20rem;">
  <img class="card-img-top" src="..." alt="Card image cap">
  <div class="card-body">
    <h4 class="card-title">Card title</h4>
    <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>
    <a href="#" class="btn btn-primary">Go somewhere</a>
  </div>
</div>

这是对 相关问题类似回答

原文由 Parker 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题