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%;
}
}
<div class="col-container">
<div class="col col1of4">
<div class="col__inner">sssadksadkaslkslasasldkasddsa</div>
<div class="col__inner">sssadksadkaslkslasasldkasddsa</div>
</div>
<div class="col col1of2">
<div class="col__inner">sssadksadkaslkslasasldkasddsa</div>
<div class="col__inner">sssadksadkaslkslasasldkasddsa</div>
<div class="col__inner">sssadksadkaslkslasasldkasddsa</div>
<div class="col__inner">sssadksadkaslkslasasldkasddsa</div>
</div>
<div class="col col1of4 col1of4--last">
<div class="col__inner">sssadksadkaslkslasasldkasddsa</div>
<div class="col__inner">sssadksadkaslkslasasldkasddsa</div>
</div>
</div>
Post a Comment for "Flexbox: Reorder And Stack Columns"