Skip to content

Instantly share code, notes, and snippets.

@kaelifa
Created August 15, 2014 13:52
Show Gist options
  • Save kaelifa/35d780769d6d67d3ef40 to your computer and use it in GitHub Desktop.
Save kaelifa/35d780769d6d67d3ef40 to your computer and use it in GitHub Desktop.
Flexbox test - doctype
<!DOCTYPE html>
<html>
<head>
<style media="screen">
body {
margin: 0;
padding: 0;
}
.flex__container {
display: flex;
}
.flex__sidebar {
background: violet;
display: flex;
flex-direction: column;
height: 100%;
margin: 0;
position: relative;
-webkit-user-select: none;
width: 30rem;
z-index: 1000;
}
.flex__main {
background: black;
flex: 1;
height: 100%;
margin: 0;
}
</style>
</head>
<body>
<section class="flex__container">
<aside class="flex__sidebar">
SIDEBAR
</aside>
<figure class="flex__main">
main area
</figure>
</section>
</body>
</html>
@emilbjorklund
Copy link

I think height on flexbox items (in a single row container) resolve against the height of the container, which is not explicitly set in this instance, so "collapsed" items would be correct. The doctype thing is probably indicative that the dimensions of <body> or <html> are different in quirks mode (I think. Maybe.)

What I'd do is set a min-height on the flex container (100vh if you want it to cover the viewport, for example), and then remove the height on the flex items: the default alignment is to stretch them (align-items: stretch), so they'll be 100% tall anyway. See my edited gist. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment