Skip to content

Instantly share code, notes, and snippets.

@carlos-sanchez
Last active November 10, 2016 16:17
Show Gist options
  • Save carlos-sanchez/7634720 to your computer and use it in GitHub Desktop.
Save carlos-sanchez/7634720 to your computer and use it in GitHub Desktop.
Absolute Center with flexbox. Content can be any width or height, even overflows gracefully No IE8-9 support Requires a container or styles on the body
.Center-Container.is-Flexbox {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-moz-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
-webkit-box-pack: center;
-moz-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
}
.parent{
display: flex;
}
.child{
margin: auto;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment