Someone linked me this: What is the best way to move an element that's on the top to the bottom in Responsive design.
其中的解决方案效果非常好.虽然它不支持旧的IE,但这对我来说无关紧要,因为我使用的是针对移动设备的响应式设计.而且它适用于大多数移动浏览器.
基本上,我有这个:
@media (max-width: 30em) {
.container {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-orient: vertical;
-moz-box-orient: vertical;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
/* optional */
-webkit-box-align: start;
-moz-box-align: start;
-ms-flex-align: start;
-webkit-align-items: flex-start;
align-items: flex-start;
}
.container .first_div {
-webkit-box-ordinal-group: 2;
-moz-box-ordinal-group: 2;
-ms-flex-order: 2;
-webkit-order: 2;
order: 2;
}
.container .second_div {
-webkit-box-ordinal-group: 1;
-moz-box-ordinal-group: 1;
-ms-flex-order: 1;
-webkit-order: 1;
order: 1;
}
}
对我来说,这比浮球更有效,因为我需要它们堆叠在一起,我有大约五个不同的div,我必须围绕着浮球的位置交换.