title: Flexbox: center horizontally and vertically
body: <p>How to center div horizontally, and vertically within the container using flexbox. In below example, I want each number below each other (in rows), which are centered horizontally.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.flex-container {
    padding: 0;
    margin: 0;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  row {
    width: 100%;
  }
  .flex-item {
    background: tomato;
    padding: 5px;
    width: 200px;
    height: 150px;
    margin: 10px;
    line-height: 150px;
    color: white;
    font-weight: bold;
    font-size: 3em;
    text-align: center;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="flex-container"&gt;
    &lt;div class="row"&gt;
      &lt;span class="flex-item"&gt;1&lt;/span&gt;
    &lt;/div&gt;
    &lt;div class="row"&gt;
      &lt;span class="flex-item"&gt;2&lt;/span&gt;
    &lt;/div&gt;
    &lt;div class="row"&gt;
      &lt;span class="flex-item"&gt;3&lt;/span&gt;
    &lt;/div&gt;
    &lt;div class="row"&gt;
      &lt;span class="flex-item"&gt;4&lt;/span&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <p><a href="http://codepen.io/anon/pen/zLxBo" rel="noreferrer">http://codepen.io/anon/pen/zLxBo</a></p>