Skip to content

Instantly share code, notes, and snippets.

@EvanWieland
Forked from jfsiii/index.html
Last active August 29, 2015 14:21
Show Gist options
  • Save EvanWieland/67b1a8e86821879ba5bc to your computer and use it in GitHub Desktop.
Save EvanWieland/67b1a8e86821879ba5bc to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Holy Grail</title>
<style>
/* some basic styles. nothing to do with flexbox */
header, footer,
nav, article, aside {
border: 1px solid black;
padding: 0.25em;
margin: 0.25em;
border-radius: 0.25em;
}
/*
Force full width & height.
If this block is removed, the layout height/length will be determined by
the amount of content in the page. That might result in a page which has
a footer only a few inches from the top of the viewport, or one which
scrolls beyond the viewport.
This forces the layout to always be full screen regardless of how much,
or how little, content is in place. Neither is "right" or "wrong", there
are valid cases for each. I just want to be clear what's controlling the
page/viewport height.
*/
html, body, .viewport {
width: 100%;
height: 100%;
margin: 0;
}
/* encapsulate the various syntax in helper clases */
/* inspired by http://infrequently.org/2009/08/css-3-progress/ */
/* items flex/expand vertically */
.vbox {
/* previous syntax */
display: -webkit-box;
display: -moz-box;
display: box;
-webkit-box-orient: vertical;
-moz-box-orient: vertical;
-ms-box-orient: vertical;
box-orient: vertical;
/* current syntax */
display: -webkit-flex;
display: -moz-flex;
display: -ms-flex;
display: flex;
-webkit-flex-direction: column;
-moz-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
}
/* items flex/expand horizontally */
.hbox {
/* previous syntax */
display: -webkit-box;
display: -moz-box;
display: -ms-box;
display: box;
-webkit-box-orient: horizontal;
-moz-box-orient: horizontal;
-ms-box-orient: horizontal;
box-orient: horizontal;
/* current syntax */
display: -webkit-flex;
display: -moz-flex;
display: -ms-flex;
display: flex;
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
}
.space-between {
/* previous syntax */
-webkit-box-pack: justify;
-moz-box-pack: justify;
-ms-box-pack: justify;
box-pack: justify;
/* current syntax */
-webkit-justify-content: space-between;
-moz-justify-content: space-between;
-ms-justify-content: space-between;
justify-content: space-between;
}
/* I went with a fixed height header & footer because it's a common case.
This could easily be altered to flex proportionally with the page.
*/
header, footer {
height: 100px;
}
.main {
/* previous syntax */
-webkit-box-flex: 1;
-moz-box-flex: 1;
-ms-box-flex: 1;
box-flex: 1;
/* current syntax */
-webkit-flex: 1;
-moz-flex: 1;
-ms-flex: 1;
flex: 1;
}
article {
/* previous syntax */
-webkit-box-flex: 5;
-moz-box-flex: 5;
-ms-box-flex: 5;
box-flex: 5;
/* current syntax */
-webkit-flex: 5;
-moz-flex: 5;
-ms-flex: 5;
flex: 5;
}
aside, nav {
/* previous syntax */
-webkit-box-flex: 1;
-moz-box-flex: 1;
-ms-box-flex: 1;
box-flex: 1;
/* current syntax */
-webkit-flex: 1;
-moz-flex: 1;
-ms-flex: 1;
flex: 1;
}
</style>
</head>
<body class="vbox viewport">
<header>Header</header>
<section class="main hbox space-between">
<nav>Nav</nav>
<article>Article</article>
<aside>Aside</aside>
</section>
<footer>Footer</footer>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment