Mazodude Mazodude - 7 months ago 15
HTML Question

How to change the ordering of two divs when on mobile?

I am trying to change the order of two divs in a container when they get to mobile size.

<div class="container">
<div class="div1"></div>
<div class="div2"></div>
</div>


Is this possible to change it so that it will change to

<div class="container">
<div class="div2"></div>
<div class="div1"></div>
</div>

Answer

You can use pure css to do that

.container{
    display:table;
}
.div1{
    display:table-footer-group;
}
.div2{
    display:table-header-group;
}

make sure you put it in a @media query.

Comments