【问题标题】:Bootstrap 4 column order not working on mobile [duplicate]Bootstrap 4列顺序在移动设备上不起作用[重复]
【发布时间】:2018-07-28 20:45:45
【问题描述】:

我想使用 bootstrap 4 中的 order-width-pos,但由于某种原因,它在移动视图上不起作用。它工作正常,直到它捕捉到移动视图大小,我不知道为什么。

https://codepen.io/anon/pen/zRpQeG

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<section>
  <div class="container">
    <div class="row ">
      
      <div class="col-xl-3 col-lg-6 col-md-6 col-sm-6 order-xs-last order-md-last order-lg-first box">
        <h1>col 1</h1>
        <hr/>
      </div>

      <div class=" col-xl-3 col-lg-6 col-md-6 col-lg-6 order-xs-first order-lg-first box">
        <h1>Col 2</h1>
        <hr/>
        </div>

      <div class=" col-xl-6 col-md-12 order-md-first order-xs-first order-lg-last box">
        <h1>Col 3</h1>
        <hr/>
      </div>

    </div>
  </div>
</section>

【问题讨论】:

    标签: html css layout bootstrap-4


    【解决方案1】:

    Bootsrtrap V4 中没有更多的xs,所以删除它就可以了。

    新版本的 Bootstrap 是移动优先的,所以没有前缀(smmdlg)相当于超小设备。如果您指定sm,它相当于small 设备及更高版本。

    如你所见in the documentation:

    网格断点基于最小宽度媒体查询,这意味着 它们适用于那个一个断点和所有高于它的断点(例如, .col-sm-4 适用于小型、中型、大型和超大型设备, 但不是第一个 xs 断点)

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    
    <section>
      <div class="container">
        <div class="row ">
          
          <div class="col-xl-3 col-lg-6 col-md-6 col-sm-6 order-last order-md-last order-lg-first box">
            <h1>col 1</h1>
            <hr/>
          </div>
    
          <div class=" col-xl-3 col-lg-6 col-md-6 col-lg-6 order-first order-lg-first box">
            <h1>Col 2</h1>
            <hr/>
            </div>
    
          <div class=" col-xl-6 col-md-12 order-md-first order-first order-lg-last box">
            <h1>Col 3</h1>
            <hr/>
          </div>
    
        </div>
      </div>
    </section>

    【讨论】:

    • 谢谢 不知道,可能一遍又一遍地阅读..
    猜你喜欢
    • 1970-01-01
    • 2020-12-21
    • 1970-01-01
    • 1970-01-01
    • 2020-07-03
    • 1970-01-01
    • 2016-01-27
    • 2014-01-30
    • 2014-06-08
    相关资源
    最近更新 更多