Skip to content

Instantly share code, notes, and snippets.

@rolka
Forked from anonymous/index.html
Created April 15, 2014 23:18
Show Gist options
  • Save rolka/10787898 to your computer and use it in GitHub Desktop.
Save rolka/10787898 to your computer and use it in GitHub Desktop.
centering css
<div class="container">
<div class="box">
</div>
</div>
.container {
height: 300px;
width: 300px;
background: #eee;
position: absolute;
margin: -150px 0 0 -150px;
left: 50%;
top: 50%;
}
.box {
height: 100px;
width: 100px;
background: #222;
position: absolute;
/*Centering Method 2*/
margin: -50px 0 0 -50px;
left: 50%;
top: 50%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment