Skip to content

Instantly share code, notes, and snippets.

@cahnory
Created February 3, 2012 20:36
Show Gist options
  • Save cahnory/1732349 to your computer and use it in GitHub Desktop.
Save cahnory/1732349 to your computer and use it in GitHub Desktop.
Centrage horizontal et vertical — universel
/**
* Centrage horizontal et vertical — universel
*/
html, body {
height: 100%;
margin: 0;
width: 100%;
}
.layout {
display: table;
height: 100%;
overflow: hidden;
text-align: center;
width: 100%;
*position: relative;
}
.layout-wrapper {
display: table-cell;
vertical-align: middle;
width: 100%;
*left: 0;
*position: absolute;
*top: 50%;
}
.layout-content {
display: -moz-inline-stack;
display: inline-block;
text-align: left; /* Retour à l'alignement classique, non nécessaire */
*display: inline;
*left: 0;
*position: relative;
*zoom: 1;
*top: -50%;
}
<div class="layout">
<div class="layout-wrapper">
<div class="layout-content">
<div contenteditable="true">
Vous êtes<br />
centré !
</div>
</div>
</div>
</div>
{"view":"split","prefixfree":"1","page":"html"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment