Created
February 12, 2015 16:12
-
-
Save JustinTulloss/c6456f40f7877461089a to your computer and use it in GitHub Desktop.
Simple Flexbox Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Flexbox</title> | |
<style> | |
html, body { | |
height: 100%; | |
} | |
body { | |
margin: 0; | |
padding: 0; | |
display: flex; | |
flex-direction: column; | |
} | |
div, span, header, nav, section { | |
box-sizing: border-box; | |
position: relative; | |
border: 0 solid black; | |
margin: 0; | |
padding: 0; | |
display: flex; | |
flex-direction: column; | |
} | |
header { | |
background: blue; | |
color: white; | |
flex: 0 0 50px; | |
align-items: center; | |
justify-content: center; | |
} | |
header h1 { | |
margin: 0; | |
} | |
nav { | |
background: red; | |
flex-direction: row; | |
flex: 0 0 50px; | |
align-items: center; | |
} | |
nav span { | |
flex: 1; | |
text-align: center; | |
overflow: hidden; | |
white-space: nowrap; | |
transition: .2s flex; | |
} | |
nav span.conditional { | |
flex: .00001; | |
} | |
@media (max-width: 600px) { | |
nav span.conditional { | |
flex: 1; | |
} | |
} | |
.content { | |
background: green; | |
flex: 1 0 auto; | |
align-items: center; | |
justify-content: center; | |
} | |
</style> | |
</head> | |
<body> | |
<header><h1>This is the header</h1></header> | |
<nav><span class="conditional">Nav item 3</span><span>Nav item 1</span><span>Nav item 2</span></nav> | |
<section class="content"><p>Hi</p></section> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment