Use flexbox
and its order
property
I recommend a .wrapper
, though you can use it on the body
as well and get the same result
@media screen and (max-width: 800px) {
.wrapper {
display: flex;
flex-direction: column;
}
.wrapper div:first-child {
order: 1;
}
}
<div class="wrapper">
<div>1</div>
<div>2</div>
</div>
If flexbox
isn't an option, you can use display: table
@media screen and (max-width: 800px) {
.wrapper {
display: table;
width: 100%;
}
.wrapper div:nth-child(1) {
display: table-footer-group;
}
}
<div class="wrapper">
<div>1</div>
<div>2</div>
</div>