【发布时间】:2017-08-03 22:05:54
【问题描述】:
在小屏幕上,我试图让我的 .image div 插入 .title 和 .text div 之间,类似于:
title
image
text
.title 和 .text 被包装在一个容器中,这是在不同的屏幕尺寸(中等以上)上我可以做到的:
title | image
text | continuation of image element
我考虑过在小屏幕上使用弹性列布局,并更改元素的顺序,但顺序似乎对嵌套的子元素没有影响。
这是小号的代码:
HTML:
<div class="container">
<div class="content">
<div class="title"></div>
<div class="text"></div>
</div>
<div class="image"></div>
</div>
CSS:
.container {
display: flex;
flex-direction: column;
}
.image {
order: 2;
}
.title {
order: 1;
}
.text {
order: 3;
}
作为参考,我的中等代码是(从小向上级联):
.container {
flex-direction: row;
}
.content {
flex-basis: 50%;
}
.image {
flex-basis: 50%;
}
【问题讨论】:
-
这样你无法达到你的要求。它不起作用,因为图像本身在您的内容 div 之外。所以它不会锻炼。