开发者

Bootstrap stack columns and change order

开发者 https://www.devze.com 2022-12-07 17:38 出处:网络
Here\'s an image of what I would like to change Currently the page has 2 main columns, a sidebar on the left with some rows and a main body on the right. A 3x9 setup. I want the 1st row on the 1st co

Here's an image of what I would like to change

Bootstrap stack columns and change order

Currently the page has 2 main columns, a sidebar on the left with some rows and a main body on the right. A 3x9 setup. I want the 1st row on the 1st column to move to the very bottom in a mobile view. I thought about seperating the 1st col into 2 different ones and stack them on top of each other and then just change col order on mobile view. But I have no idea how to achieve that...

How the grid looks in html:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.sl开发者_StackOverflow中文版im.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script>

<div class="container">
  <div class="row">
    <div class="col-lg-3">
      <div class="row">
        <!-- The row I want to move to the very bottom in a mobile view -->
      </div>
      <div class="row">
      </div>
      <div class="row">
      </div>
      <div class="row">
      </div>
    </div>
    <div class="col-lg-9">
      <!-- Content -->
    </div>
  </div>
</div>


Make 1st row two times:

  • show one on desktop (using Bootstrap classes d-lg-block d-none) and
  • show one on mobile (using Bootstrap classes d-lg-none d-block).

See the snippet below.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script>

<div class="container">
  <div class="row">
    <div class="col-lg-3">
      <div class="row d-lg-block d-none">
        <!-- Desktop -->
        Show me on desktop
      </div>
      <div class="row">
        Row
      </div>
      <div class="row">
        Row
      </div>
      <div class="row">
        Row
      </div>
    </div>
    <div class="col-lg-9 px-0">
      Content
    </div>
  </div>
  <div class="row d-lg-none d-block">
    <!-- Mobile -->
    Show me on mobile
  </div>
</div>

0

精彩评论

暂无评论...
验证码 换一张
取 消