Skip to content

Instantly share code, notes, and snippets.

@schadeck
Created May 19, 2012 15:04
Show Gist options
  • Save schadeck/2731158 to your computer and use it in GitHub Desktop.
Save schadeck/2731158 to your computer and use it in GitHub Desktop.
Absolute Centering
/**
* Absolute Centering
*/
div { width: 300px; height: 250px; background: green; position: relative;}
div div { width: 50%; height: 50%; background: blue;}
.center {
position: absolute;
top:0;
left:0;
right:0;
bottom: 0;
margin: auto;
}
<!-- content to be placed inside <body>…</body> -->
<div>
<div class="center"></div>
</div>
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment