Given a template where the HTML cannot be modified because of other requirements, how is it possible to display (rearrange) a div
above another div
This can be done using Flexbox.
Create a container that applies both display:flex and flex-flow:column-reverse.
/* -- Where the Magic Happens -- */
.container {
/* Setup Flexbox */
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
/* Reverse Column Order */
-webkit-flex-flow: column-reverse;
flex-flow: column-reverse;
}
/* -- Styling Only -- */
.container > div {
background: red;
color: white;
padding: 10px;
}
.container > div:last-of-type {
background: blue;
}
first
second
Sources: