Stephan Muller
Stephan Muller

Reputation: 27630

"Holy Grail" three column layout using flexbox

I'm trying to achieve the three-column layout generally described as the "holy grail" (see this ALA article) using the new display: flex syntax.

The requirements are as follows:

I got the first three requirements down with the following code:

<body>
<div class="container">
  <header class="masthead">
    <h1>The Header</h1>
  </header>
  <div class="side-left column">
    Left sidebar  
  </div>
  <div class="middle column">     
    Content goes here
  </div>
  <div class="side-right column">
    Right sidebar
  </div>  
  <footer class="footer">
    &copy; Footer
  </footer>
</div>
</body>

CSS:

.container {
  display: flex;
  flex-flow: row wrap;
  min-width: 500px;
  max-width: 1100px;
}
.masthead {
  flex: 1 100%;
}   
.side-left,
.side-right {
  flex: 0 0 150px;
}
.middle {
  flex: 1;
}
.footer {
  flex: 1 100%;
}

Live in action: jsBin

However, I'm stuck with the 100% height. I already tried setting either some of the columns or the container to height: 100% or min-height: 100% but none seem to work. Do I need one of the many other flex properties to handle this? I can't seem to see the forest through the trees.

Upvotes: 4

Views: 2453

Answers (1)

AdmireNL
AdmireNL

Reputation: 406

.container { min-height: 100vh; }

Upvotes: 3

Related Questions