Skip to content

Instantly share code, notes, and snippets.

@gabelloyd
Created December 17, 2013 22:24
Show Gist options
  • Select an option

  • Save gabelloyd/8013728 to your computer and use it in GitHub Desktop.

Select an option

Save gabelloyd/8013728 to your computer and use it in GitHub Desktop.
A Pen by Gabe Lloyd.

Flexbox with 4 asides

Test layout for wrapping with flexbox. Two top asides over main content.

A Pen by Gabe Lloyd on CodePen.

License.

<div class="wrapper">
<header class="header">Header</header>
<aside class="aside aside-1">Aside 1</aside>
<aside class="aside aside-2">Aside 2</aside>
<article class="main">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
</article>
<aside class="aside aside-3">Aside 3</aside>
<aside class="aside aside-4">Aside 4</aside>
<footer class="footer">Footer</footer>
</div>
@import "compass";
.wrapper {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-flow: row wrap;
font-weight: bold;
text-align: center;
}
.wrapper > * {
padding: 10px;
flex: 1 100%;
}
.header {
background: tomato;
}
.footer {
background: lightgreen;
}
.main {
text-align: left;
background: deepskyblue;
}
.aside {
min-height: 300px;
}
.aside-1 {
background: gold;
}
.aside-2 {
background: hotpink;
}
.aside-3 {
background: teal;
}
aside-4 {
background: red;
}
@media all and (max-width: 1024px) {
.main { flex: 2 0px; }
.main { order: 3; }
.aside-1 { order: 1; }
.aside-2 { order: 2; }
.aside-3 { order: 4; }
.aside-4 { order: 5; }
.footer { order: 6; }
}
@media all and (min-width: 600px) {
.aside { flex: 1 auto; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment