Created
March 29, 2017 13:42
-
-
Save GarySwift/a2ca89f9594c120e2bef13a0ec903c69 to your computer and use it in GitHub Desktop.
CSS Vertical Center with Flexbox
This file contains hidden or 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
| /* 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; | |
| } |
This file contains hidden or 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
| <div class="flexbox-container"> | |
| <div>Blah blah</div> | |
| <div>Blah blah blah blah blah ...</div> | |
| </div> |
Author
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
Thanks to David Walsh: https://davidwalsh.name/css-vertical-center-flexbox