html - 在最大宽度 480px 处反转行的顺序

标签 html css

我有一个正常的 html/css 布局,如下所示。但是,对于 max-width 480px,我想颠倒 section1 和 section2 的顺序。我使用 Bootstrap 。

我希望 section2 行位于 section1 行之前。我该怎么做?

    <div class="container" id="content">
        <div class="row" id="section1">
        </div>
        <div class="row" id="section2">
        </div>
        <div class="row" id="section3">
        </div>
    </div>
    <footer>
    </footer>

最佳答案

您可以使用 flexbox 并更改要重新排序的 child 的 order 属性。

@media (max-width: 480px) {
  .container {
    display: flex;
    flex-direction: column;
  }
  #section2 {
    order: -1;
  }
}
<div class="container" id="content">
  <div class="row" id="section1">1
  </div>
  <div class="row" id="section2">2
  </div>
  <div class="row" id="section3">3
  </div>
</div>

关于html - 在最大宽度 480px 处反转行的顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42449364/

相关文章:

java - 无法使用 html 发送超链接 key

javascript - 模拟人类在选择菜单中选择选项

html - 如何将 LI 的高度固定为与另一个 LI 一样高

html - 试图在页面中居中定价表

javascript - 为什么我的背景图片在某个元素上没有变化?

html - 我怎样才能修复大纲并不总是在最上面

html - 导航栏崩溃在 Bootstrap 中不起作用

动画中的 CSS Slide 在段落和 h1 上工作但不在 div 上工作

html - 当用户仅使用 css 放大时,是否可以保持 <div> 元素的大小不变?

javascript - 单击时如何将 td-tag 更改为 html 中的 input-tag?