Skip to content

Instantly share code, notes, and snippets.

@csssecrets
Created November 13, 2014 11:57
Show Gist options
  • Save csssecrets/00b5cd0de91a439616e8 to your computer and use it in GitHub Desktop.
Save csssecrets/00b5cd0de91a439616e8 to your computer and use it in GitHub Desktop.
Vertical centering - Flexbox solution for text
/**
* Vertical centering - Flexbox solution for text
*/
body {
display: flex;
align-items: center;
min-height: 100%;
margin: 0;
}
html { height: 100% }
main {
display: flex;
justify-content: center;
align-items: center;
width: 18em;
height: 10em;
padding: 1em 1.5em;
margin: 0 auto;
box-sizing: border-box;
background: #655;
color: white;
text-align: center;
}
h1 {
margin: 0 0 .2em;
font-size: 150%;
}
p {
margin: 0;
}
body {
background: #fb3;
font: 100%/1.5 sans-serif;
}
<main>
Center me, please!
</main>
// alert('Hello world!');
{"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