BTN不正确

时间:2018-11-21 12:50:29

标签: css twitter-bootstrap

我想在左侧放置一个h5“帖子”,在右侧放置一个按钮“ Btn”,但是.col div的左侧不位于“ Btn”右侧,您知道如何正确定位右边的按钮?使用“ justify-content-end”不起作用。

我也想在每行中有4张宽度相等的卡片,但是您知道为什么卡片出现那么长吗?该卡不可能像正方形而不是矩形吗?

示例:http://jsfiddle.net/1b790tL5/

HTML:

<div class="container">
  <div class="row">
    <div class="col">
      <h5 class="display-5 font-weight-bold text-dark">Posts</h5>
    </div>
    <div class="col justify-content-end">
      <a href="" class="btn btn-primary">Btn</a>
    </div>
  </div>
</div>

<div class="container mt-4">
  <div class="card-deck">
    <div class="card p-0 shadow">
      <img class="card-img-top border-bottom" src="https://via.placeholder.com/280" alt="Card image cap">
      <div class="card-body">
        <h5 class="card-title text-dark font-weight-bold">Card title</h5>
        <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional
          content.</p>
      </div>
    </div>
    <div class="card p-0 shadow">
      <img class="card-img-top border-bottom" src="https://via.placeholder.com/280" alt="Card image cap">
      <div class="card-body">
        <h5 class="card-title text-dark font-weight-bold">Card title</h5>
        <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional
          content. This content is a little bit longer.</p>
      </div>
    </div>
     <div class="card p-0 shadow">
      <img class="card-img-top border-bottom" src="https://via.placeholder.com/280" alt="Card image cap">
      <div class="card-body">
        <h5 class="card-title text-dark font-weight-bold">Card title</h5>
        <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional
          content. This content is a little bit longer.</p>
      </div>
    </div>
     <div class="card p-0 shadow">
      <img class="card-img-top border-bottom" src="https://via.placeholder.com/280" alt="Card image cap">
      <div class="card-body">
        <h5 class="card-title text-dark font-weight-bold">Card title</h5>
        <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional
          content. This content is a little bit longer.</p>
      </div>
    </div>
  </div>
</div>

1 个答案:

答案 0 :(得分:0)

请参考下图。当您使用col类时,项的宽度相等。为了控制宽度,请根据框架在col-10或12中添加一个类似col-1的数字。

enter image description here