Bootstrap 4:在网格单元内将内容右对齐

时间:2018-07-24 08:57:32

标签: html twitter-bootstrap bootstrap-4

在小屏幕上的以下html导致列重叠:

<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://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>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

<div class="row">
  <div class="col-sm-1">
    <a class="btn btn-secondary">New</a>
  </div>
  <div class="col-sm-8">
    <form method="get">
      <div class="row form-group">
        <div class="col-8">
          <input name="custName" value="" class="form-control" placeholder="Customer" />
        </div>
        <div class="col-4">
          <button type="button" class="btn btn-secondary">Seach</button>
          <button type="button" class="btn btn-secondary">Clear</button>
        </div>
      </div>
    </form>
  </div>
  <div class="col-sm-3">
    <nav aria-label="Pagination">
      <ul class="pagination float-right">
        <li><a class="page-link" href="#">Prev</a></li>
        <li><a class="page-link" href="#">1</a></li>
        <li><a class="page-link" href="#">2</a></li>
        <li><a class="page-link" href="#">3</a></li>
        <li><a class="page-link" href="#">Next</a></li>
      </ul>
    </nav>
  </div>
</div>

Screenshot

我需要右对齐导航元素。如何防止列重叠?

1 个答案:

答案 0 :(得分:0)

这不是错误。它正在作为设计。只能有一定数量的空间,显然您不能将所有内容都放在那儿,并期望它们看起来仍然不错并且排成一排。

您可以将断点从sm更改为lg,以便这些列更早地成为行?

小提琴: http://jsfiddle.net/aq9Laaew/111085/