【发布时间】:2016-04-28 05:58:56
【问题描述】:
我正在尝试从此(移动设备)实现基于 flexbox 的过渡:
至此(桌面):
但是我很难垂直堆叠两个侧面板,我自己的代码在一行中生成主面板、搜索面板和其他面板。为简洁起见,我没有插入 webkit 代码。
代码:
p {
padding: 10px;
}
.flex-container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.header {
flex: 1 0 100%;
background-color: pink;
}
.search {
flex: 1 100%;
background-color: yellow;
}
.main {
flex: 1 100%;
background-color: lightblue;
}
.other {
flex: 1;
background-color: Red;
}
@media (min-width: 600px) {
.flex-container {} .search {
flex: 1 0;
order: 2
}
.main {
flex: 3 0;
order: 1;
}
.other {
flex: 1 0;
order: 3
}
}
<div class="flex-container">
<div class="header">
<p>header</p>
</div>
<div class="search">
<p>search</p>
</div>
<div class="main">
<p>main</p>
</div>
<div class="other">
<p>other</p>
</div>
</div>
jsFiddle:https://jsfiddle.net/azizn/d2pmdvc4/
【问题讨论】:
-
ttp://stackoverflow.com/help/how-to-ask
-
一张图片胜过千言万语。还提供您目前拥有的代码。
-
欢迎来到 Stack Overflow!预计您至少会尝试自己编写代码。 Stack Overflow 不是代码编写服务。我建议你做一些额外的研究,无论是通过谷歌还是通过搜索,尝试一下。如果您仍然遇到问题,请返回您的代码并解释您尝试过的方法以及为什么它不起作用。