I am facing an issue with two divs, left and right, on my webpage. When the screen size is less than 500px, I want the left div to move to the bottom and the right div to move to the top. Essentially, I need to swap the positions of these divs in the DOM.
https://i.sstatic.net/iK6YK.png
Currently, I am using display: flex
, but when I reverse the order of the divs, they display inline and do not respect the 100% width property. What am I doing wrong?
HTML
<div class='nav'>
<div class='container'>
<div class='left_bottom'>
LEFT/BOTTOM
</div>
<div class='right_top'>
RIGHT/TOP
</div>
</div>
</div>
CSS
.nav{
background-color: red;
}
.container{
width: 100%;
}
.left_bottom{
padding: 15px 0 15px 0;
background-color: green;
float: left;
width: 33.33%;
text-align: center;
}
.right_top{
padding: 15px 0 15px 0;
background-color: blue;
float: right;
width: 66.66%;
text-align: center;
}
@media (max-width: 500px){
.left_bottom{
float: left;
width: 100%;
}
.right_top{
float: left;
width: 100%;
}
.container{
display: flex;
flex-direction: row-reverse;
}
}