Bootstrap Column Order 3

时间:2017-03-08 13:24:57

标签: css twitter-bootstrap-3

如何重新排序Bootstrap 3中的列?

在桌面视图中

[A - 60% block] [B - 40% block]
[C - full block]

在平板电脑和移动视图中

[A - long block]
[C - long block]
[B - long block]

HTML代码

<div class="row">
    <div class="col-sm-8">A</div>
    <div class="col-sm-4">B</div>
    <div class="col-sm-12">C</div>
</div>

1 个答案:

答案 0 :(得分:2)

HTML:

<div class="container">
  <div class="row">
    <div id="a" class="col-md-7 col-sm-12 col-xs-12">A</div>
    <div class="reorder-sm">
      <div id="b" class="col-md-5 col-sm-12 col-xs-12">B</div>
      <div id="c" class="col-md-12 col-sm-12 col-xs-12">C</div>
    </div>
  </div>
</div>

的CSS:

@media (max-width: 991px) {
  .reorder-sm {
     -webkit-transform: rotate(180deg);
     -moz-transform: rotate(180deg);
     -ms-transform: rotate(180deg);
     -o-transform: rotate(180deg);
     transform: rotate(180deg);

     direction: rtl;
  }

  .reorder-sm > [class*="col-"] {
    -webkit-transform: rotate(-180deg) translate(0,300%);
    -moz-transform: rotate(-180deg) translate(0,300%);
    -ms-transform: rotate(-180deg) translate(0,300%);
    -o-transform: rotate(-180deg) translate(0,300%);
    transform: rotate(-180deg) translate(0,300%);

    direction: ltr;
  }
}

有关完整解决方案,请参阅fiddle。您可能还会发现this similar question有帮助。

另一种解决方案:

<div id="a" class="col-md-7 col-sm-12 col-xs-12">A</div>
<div id="b1" class="col-md-5 hidden-sm hidden-xs">B</div>
<div id="c" class="col-md-12 col-sm-12 col-xs-12">C</div>
<div id="b2" class="visible-sm visible-xs col-sm-12 col-xs-12">B</div>