switching stack order of floats with flex

responsive stacking, changing the order of how they stack. so by default they should stack in order they are listed in, like if the pink box is 1st then it should stack on top of the blue box when it goes under 800px width. by using the flex and order we can change the order in which they stack at 800px

Example switching the order

Codepen Example

See the Pen Grid Stacking by Luke (@kruxor) on CodePen.

HTML

<div class="wrapper">
    <div class="pink">
    </div>
    <div class="blue">
    </div>
</div>

CSS

.wrapper {
  display: flex;
  flex-flow: row wrap;
}

.pink {
    background: pink;
    width: 50%;
    height: 300px;
}

.blue {
    background: blue;
    width: 50%;
    height: 300px;
}

@media screen and (max-width:800px) {
    .pink {
        order: 2;
        width: 100%;
    }

    .blue {
        order: 1;
        width: 100%;
    }
}

Other Items in css

No Items Found.

Add Comment
Type in a Nick Name here
 
Page Views

This page has been viewed 667 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

โค๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ•น

Random Quote
When I realized that, no individual step is hard in any process. Building this airport I'm standing in right now started with a guy writing the architectural plans on paper. That's not hard for him to do. Then laying the first beam isn't had. The whole thing is really hard. So, just take each step kind of piece by piece and when I was able to do that and stop trying to chase this prize and started putting in the work, things just started coming together.
Unknown