Is there a way to ensure that the yellow box is placed below the blue box on smaller screen sizes?
I have realized that since the yellow box is not a sibling to the other boxes, it does not behave as expected. How can I rectify this issue?
.container1 {
display: flex;
flex-flow: column;
}
.container2 {
display: flex;
flex-flow: row;
}
.box {
border: 1px solid black;
width: 50px;
height: 50px;
margin: 5px 5px 5px 5px;
}
#b1 {
background-color: red;
}
#b2 {
background-color: blue;
}
#b3 {
background-color: green;
}
#b4 {
background-color: yellow;
}
@media screen and (max-width:500px) {
.container2 {
display: flex;
flex-flow: column;
}
#b1 {
order: 1;
-webkit-order: 1;
}
#b2 {
order: 2;
-webkit-order: 2;
}
#b3 {
order: 4;
-webkit-order: 4;
}
#b4 {
order: 3;
-webkit-order: 3
}
}
<div class="container1">
<div class="container2">
<div class="box" id="b1"></div>
<div class="box" id="b2"></div>
<div class="box" id="b3"></div>
</div>
<div class="box" id="b4"></div>
</div>
In order to comply with SO guidelines, I am adding more text here. But I believe all relevant information has been covered in the above content :)