Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Stacking divs responsively

Stacking divs responsively

Problem

I am working on a responsive site that when on desktop / large Screen it will be in the following layout.

  1. Header
  2. Menu
  3. Content

Then when it's in phone / small screen it will be

  1. Header
  2. Content
  3. Menu

How can do this? The examples I've seen all seem to use absolute positioning, but I want it to be dynamic to the size of the screen and size / move dynamically.

Thanks!

Problem courtesy of: alinitro

Solution

You can use CSS3 flexbox box-direction: reverse; property. Write like this:

.flex{
    display: -moz-box;
    -moz-box-orient:vertical;
    -webkit-box-orient:vertical;
    display: -webkit-box;
    box-orient:vertical;
    display:box;
    width:100%;
}
.flex div, .header{
    border:1px solid red;
    height:100px;    
}


@media screen and (max-width : 400px){
    .flex{
    -moz-box-direction: reverse;
    -webkit-box-direction: reverse;
    box-direction: reverse;
}
}

Check this http://jsfiddle.net/Hj5pz/

Solution courtesy of: sandeep

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

Stacking divs responsively

×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×