【问题标题】:Change the order of col-*-12 columns in Bootstrap 3 using push/pull使用推/拉更改 Bootstrap 3 中 col-*-12 列的顺序
【发布时间】:2021-02-03 10:39:30
【问题描述】:

我有一个小问题。 我在 xs 和 sm 上有这样的三列:

[A]

[B]

[C]

在 md 和 lg 上,我想要这个:

[B]

[A][C]

这个我试过了,还是不行:

<div class="col-xs-12 col-md-8 col-md-push-12">
  Col A
</div>
<div class="col-xs-12 col-md-12 col-md-pull-12">
  Col B
</div>
<div class="col-xs-12 col-md-4">
  Col C
</div>

A列和B列在外面:(

谢谢

【问题讨论】:

  • 我认为使用引导程序无法更改元素的顺序,但您可以使用 CSS 网格来做到这一点

标签: twitter-bootstrap push pull


【解决方案1】:

您可以轻松地在引导程序with the order classes. 中重新排序列

使用 .order- 类来控制内容的视觉顺序。这些类是响应式的,因此您可以通过断点设置顺序(例如,.order-1.order-md-2)。

关于如何在小屏幕上重新排列 Col B 和 Col C 的示例:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="row">
  <div class="col-xs-12 col-md-8 ">
    Col A
  </div>
  <div class="col-xs-12 col-md-12 order-sm-3">
    Col B
  </div>
  <div class="col-xs-12 col-md-4 order-sm-2">
    Col C
  </div>
</div>

【讨论】:

  • 感谢您的回答,但您的代码仅适用于 Bootstrap 4,而我使用的是 Bootstrap 3 :(
  • 没有办法用基本的 bootstrap3 重新排序,你只能用 flexbox 或 grid 重新排序。请从您正在使用的引导标签中阅读此说明:For questions related to a version of Bootstrap also use the specific version's tag from "twitter-bootstrap-2", "twitter-bootstrap-3" and "bootstrap-4" tags.
猜你喜欢
  • 2014-11-01
  • 2017-01-15
  • 1970-01-01
  • 2016-11-09
  • 1970-01-01
  • 2013-10-02
  • 2016-08-01
  • 2015-06-12
  • 2013-11-24
相关资源
最近更新 更多