Skip to content

Instantly share code, notes, and snippets.

@waldyrious
Created December 8, 2012 22:30
Show Gist options
  • Save waldyrious/4242274 to your computer and use it in GitHub Desktop.
Save waldyrious/4242274 to your computer and use it in GitHub Desktop.
Center the contents of a html page
html, body { height: 100% /* html also needs height:100% */ }
body {
display: -moz-box;
-moz-box-pack: center;
-moz-box-align: center;
-moz-box-orient: vertical;
display: -webkit-box;
-webkit-box-pack: center;
-webkit-box-align: center;
-webkit-box-orient: vertical;
display: box; /* enable box- properties */
box-pack: center; /* center vertically */
box-align: center; /* center horizontally */
box-orient: vertical; /* default is horizontal stacking */
width: 100%; /* display:box makes width collapse */
margin: 0; /* body has a margin by default and will make scrollbars appear */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment