Skip to content

Instantly share code, notes, and snippets.

@GarySwift
Created March 29, 2017 13:42
Show Gist options
  • Select an option

  • Save GarySwift/a2ca89f9594c120e2bef13a0ec903c69 to your computer and use it in GitHub Desktop.

Select an option

Save GarySwift/a2ca89f9594c120e2bef13a0ec903c69 to your computer and use it in GitHub Desktop.
CSS Vertical Center with Flexbox
/* Ref: https://davidwalsh.name/css-vertical-center-flexbox */
/*
Vertical centering requires a parent and children elements but
only the parent element needs CSS properties set for the vertical
centering of child elements:
*/
.flexbox-container {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-align: center;
-webkit-align-items: center;
-webkit-box-align: center;
align-items: center;
}
<div class="flexbox-container">
<div>Blah blah</div>
<div>Blah blah blah blah blah ...</div>
</div>
@GarySwift
Copy link
Author

@GarySwift
Copy link
Author

This will vertical center and align left. Add `justify-content: center;' to center align.

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