给定以下标记:
<div class="foo">
<div class="a"></div>
<div class="b"></div>
<div class="c"></div>
</div>
还有CSS:
.foo {
display: flex;
flex-wrap: wrap;
}
.a {
flex: none;
width: 50%;
height: 100px;
background: green;
}
.b {
flex: none;
width: 50%;
height: 200px;
background: blue;
}
.c {
flex: none;
width: 50%;
height: 100px;
background: red;
}
有没有办法将红盒子放在上一行流中?我希望避免修改标记。
这里的想法是元素在纵向和横向模式下应该有不同的布局,并且CSS-only实现的唯一方法是使用具有order
属性的flexbox。据我所知,使用中间元素会锁定其子代。