Flexbox: Reorder And Stack Columns
I have three columns, which I want to swap the order of at a certain screen size. The current order is two 1/4 width columns with a 1/2 width in between. I want to make the two 1/
Solution 1:
The key to this layout is switching the flex container to column wrap
in the media query.
You also have to define a height for the container, so the items know where to wrap.
.col-container {
display: flex;
}
.col1of2 {
width: 50%;
background: red;
}
.col1of4 {
width: 25%;
background: yellow;
}
.col1of4--last {
background: blue;
}
@media all and (max-width: 1000px) {
.col-container {
flex-direction: column;
flex-wrap: wrap;
height: 100px;
}
.col1of2 {
order: 1;
}
.col1of4 {
width: 50%;
}
}
<divclass="col-container"><divclass="col col1of4"><divclass="col__inner">sssadksadkaslkslasasldkasddsa</div><divclass="col__inner">sssadksadkaslkslasasldkasddsa</div></div><divclass="col col1of2"><divclass="col__inner">sssadksadkaslkslasasldkasddsa</div><divclass="col__inner">sssadksadkaslkslasasldkasddsa</div><divclass="col__inner">sssadksadkaslkslasasldkasddsa</div><divclass="col__inner">sssadksadkaslkslasasldkasddsa</div></div><divclass="col col1of4 col1of4--last"><divclass="col__inner">sssadksadkaslkslasasldkasddsa</div><divclass="col__inner">sssadksadkaslkslasasldkasddsa</div></div></div>
Post a Comment for "Flexbox: Reorder And Stack Columns"