Skip to content

Instantly share code, notes, and snippets.

@Vetalb8
Created August 10, 2017 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vetalb8/610f4d14a2721a3451b855bac1ecf430 to your computer and use it in GitHub Desktop.
Save Vetalb8/610f4d14a2721a3451b855bac1ecf430 to your computer and use it in GitHub Desktop.
Vertical centering - absolute positioning method
/**
* Vertical centering - absolute positioning method
*/
main {
padding: 1em 1.5em;
box-sizing: border-box;
background: #655;
color: white;
text-align: center;
width: 300px;
height: 100px;
}
h1 {
margin: 0 0 .2em;
font-size: 150%;
}
p {
margin: 0;
}
body {
background: #fb3;
font: 100%/1.5 sans-serif;
}
<main>
<h1>Am I centered yet?</h1>
<p>Center me, please!</p>
</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