html - 在移动 View 中重新排列列顺序

标签 html css responsive-design multiple-columns

我有一个 2 列布局(C1 和 C2)。

在 C1 内,我有 3 个盒子(B1、B2 和 B3)。

在 C2 里面我有 1 个盒子 (B4)。

在移动 View 中,我想使框的垂直顺序为:B1-B2-B4-B3。

如何做到这一点?我愿意使用 flex box,但发现语法有点困惑。

最佳答案

我觉得不使用flex是可以的... 你描述的效果是可以实现的(但不是使用你说的HTML结构)——调整HTML结构,把B3放在C2里面,然后把B4放在C1和C2之间。

Pen here

body {
  color: white;
  text-align: center;
  font-family: 'Arial';
}
  .c1, .c2 {
  width: 50%;
  float: left;
  clear: both;
}
.b1 {
  background: grey;
  height: 100px;
}
.b2 {
  background: dodgerblue;
  height: 100px;
}
.b3 {
  background: turquoise;
  height: 100px;
}
.b4 {
  background: gold;
  height: 100px;
  width: 50%;
  float: left;
}

@media screen and (max-width: 768px) {
  .c1, .c2 {
    width: 100%;
  }
  .b4 {
    width: 100%;
  }
}
<div class="c1">
  <div class="b1">.b1</div>
  <div class="b2">.b2</div>
</div>
<div class="b4">.b4</div>
<div class="c2">
  <div class="b3">.b3</div>
</div>

关于html - 在移动 View 中重新排列列顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30410907/

相关文章:

HTML/文本间距问题

javascript - 如何为 Javascript 错误消息提供 CSS

css - 重新格式化菜单栏 CSS 设计

CSS六 Angular 里,怎么样?

css - 根据条件更改图标的颜色

html - "Broken"<template> 标签内的链接

html - 如何使用 css 通过 href#id 隐藏 anchor 标记

html - Outlook 2010 时事通讯中的不良图像

javascript - 导航栏在不同的屏幕尺寸上无法正常工作

html - CSS - 媒体查询 - 元素未正确堆叠/ float