我有一个 Bootstrap 4 Jumbotron ,其中包含一列,根据断点设置为不同的网格宽度。
那太好了,但我还想根据断点将列设置为左或居中,具体取决于断点: center < / strong>(最多{{1})(含),左(最多md
)
lg
上的类justify-content-center
正确地将列移到了中间...
,我认为仅使用类row
即可将其推回到屏幕尺寸justify-content-lg-left
的 Jumbotron 的左,但是就像上面的图片一样停留在中间。
我还尝试只将lg
放在中心,但是在justify-content-md-center
的大小下仍然不会剩下。
如何像对lg
一样,对justify
进行响应?
代码
col-*
答案 0 :(得分:1)
尝试在全屏
中打开它用于在Bootstrap中证明内容正确的类是:
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-fluid
和d-flex
。
(2) d-flex
元素上的类row
是多余的,它们已经具有flex属性。