为什么我不能在Bootstrap 4中结合justify-content-center和justify-content-lg-left?

时间:2018-12-11 20:50:22

标签: twitter-bootstrap bootstrap-4

我有一个 Bootstrap 4 Jumbotron ,其中包含一列,根据断点设置为不同的网格宽度。

那太好了,但我还想根据断点将列设置为居中,具体取决于断点: center < / strong>(最多{{1})(含),(最多md

lg上的类justify-content-center正确地将列移到了中间...

enter image description here

,我认为仅使用类row即可将其推回到屏幕尺寸justify-content-lg-left Jumbotron ,但是就像上面的图片一样停留在中间。

我还尝试只将lg放在中心,但是在justify-content-md-center的大小下仍然不会剩下。

如何像对lg一样,对justify进行响应?

代码

col-*

2 个答案:

答案 0 :(得分:1)

尝试在全屏

中打开它

用于在Bootstrap中证明内容正确的类是:

  • justify-content-start
  • justify-content-end
  • justify-content-center

  • justify-content-around

  • justify-content-between

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="jumbotron jumbotron-fluid-flex   text-white mb-0 rounded-0 " >
    <div class="container-fluid py-5">
      <div class="row d-flex justify-content-center justify-content-lg-start">
        <div class="col-sm-12 text-center   col-md-9  text-lg-left   col-lg-8 pl-lg-3  align-self-center bg-warning">
          <h1 class="text-dark">My column content</h1>
        </div>
      </div>
    </div>
</div>

答案 1 :(得分:0)

没有justify-content-left类,其正确名称是justify-content-start。阅读the docs并检查下一个示例:

<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="jumbotron jumbotron-fluid text-white mb-0 rounded-0">
  <div class="container-fluid py-5">
    <div class="row justify-content-center justify-content-lg-start">
      <div class="col-sm-12 text-center col-md-9 text-lg-left col-lg-8 pl-lg-3 align-self-center bg-warning">
        <h1 class="text-dark">My column content</h1>
      </div>
    </div>
  </div>
</div>

另请注意:

(1) jumbotron-fluid-flex在Bootstrap上不存在。也许您都想要:jumbotron-fluidd-flex

(2) d-flex元素上的类row是多余的,它们已经具有flex属性。