【问题标题】:Bootstrap 4 Card Header on left side左侧的 Bootstrap 4 卡头
【发布时间】:2019-11-14 19:37:32
【问题描述】:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">


<div class="row">

  <div class="col-sm-3">
    <div class="card bg-light mb-3" style="max-width: 18rem;">
      <div class="card-header">Logo</div>
      <div class="card-body">
        <h5 class="card-title">Light card title</h5>
        <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>
      </div>
    </div>
  </div>


</div>

以上代码显示:

+-----------+
| Logo      |
+-----------+
|Content    |
+-----------+

但我需要它:

+------+-----------+
|Logo  | Content   |
+------+-----------+
|  Content         |
+------------------+

我需要左侧的卡片标题。我正在使用最新版本的 Bootstrap。

【问题讨论】:

  • 内容是什么? card-bodycard-titlecard-text

标签: css twitter-bootstrap bootstrap-4


【解决方案1】:

您可以使用 Bootstrap 网格来实现这一点。
根据评论中提出的问题,根据要求更新 sn-p

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  <div class="card bg-light mb-3 col-6">
    <div class="row">
      <div class="card-header col-6 border">Logo</div>
      <div class="card-body col-6 border">
        <h5 class="card-title">Light card title</h5>
        <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>
      </div>
      <div class="card-body col-12 border">
        <h5 class="card-title">Light card title</h5>
        <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>
      </div>
    </div>
  </div>
   

【讨论】:

  • 还有第三个内容?
  • @samu 检查一下。根据您的布局更新了 sn-p
  • @samu 将class="img-fluid" 应用于您的图像。它会自动调整
  • 当屏幕很小时,标题再次移动到顶部。 jsfiddle.net/dawxhLu6/1
  • @samu 看看更新的 sn-p。这是小提琴jsfiddle.net/wc1nbe8y/1
猜你喜欢
  • 2018-08-14
  • 2020-12-13
  • 2019-03-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-20
  • 1970-01-01
相关资源
最近更新 更多