Skip to content

Instantly share code, notes, and snippets.

@oksushi
Forked from LeaVerou/dabblet.css
Created May 30, 2013 11:10
Show Gist options
  • Select an option

  • Save oksushi/5677171 to your computer and use it in GitHub Desktop.

Select an option

Save oksushi/5677171 to your computer and use it in GitHub Desktop.
Vertical centering with Flexbox + margin fallback
/**
* Vertical centering with Flexbox + margin fallback
* Lea Verou & David Storey
*/
html { height: 100%; }
body {
width: 100%; /* needed for FF */
height: 100%;
margin: 0;
display: box; display: flexbox;
box-align: center; flex-align: center;
box-pack: center; flex-pack: center;
}
div {
width: 10em;
padding: 1em;
margin: 1em auto;
background: slategray;
text-align: center;
}
<div contentEditable>OMG, I’m centered!</div>
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment