Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@danielmascena
Created July 14, 2017 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielmascena/207260aed73015eb430015db1fd0f4b8 to your computer and use it in GitHub Desktop.
Save danielmascena/207260aed73015eb430015db1fd0f4b8 to your computer and use it in GitHub Desktop.
CSS Flexible Layout Module - flex property
/**
* CSS Flexible Layout Module - flex property
*/
* { transition: all 2s; box-sizing: border-box;}
body {
background: #bfbfbf;
}
header,aside,.mainContent,.extraDiv,footer {
padding: 1em;
font-size: 1.4em;
}
body {
background: #bfbfbf;
display: flex;
flex-wrap: wrap;
}
header {
background-color: blue;
order: 5;
flex: 100%;
color: white;
}
aside {
background-color: orange;
order: 4;
flex: 1 ;
}
.mainContent {
background-color: white;
order: 3;
flex: 2;
}
.extraDiv {
background-color: pink;
order: 2;
flex: 1;
}
footer {
background-color: green;
order: 1;
flex: 100%;
}
@media all and (max-width: 500px) {
footer {
order: 5;
}
header {
order: 1;
}
}
@media all and (max-width: 400px) {
/* change below 400px */
.mainContent, aside, footer, header, .extraDiv {
/* Return them to document order and make all full width*/
order: 0;
flex: none;
}
}
<header role="banner">here is the header</header>
<div class="mainContent">Here is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main contentHere is the main content</div>
<aside role="complementary">here is a sidebar, after the main content (although we want to make it appear before)</aside>
<div class="extraDiv">Oh Lord, now my head is starting to hurt!</div>
<footer role="contentInfo">here is the main footer</footer>
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment