Skip to content

Instantly share code, notes, and snippets.

@supermensa
Created April 19, 2014 12:02
Show Gist options
  • Save supermensa/11082477 to your computer and use it in GitHub Desktop.
Save supermensa/11082477 to your computer and use it in GitHub Desktop.
Dead centre a div
body
{
margin: 0px
}
#horizon
{
color: white;
background-color: #0ff;
text-align: center;
position: absolute;
top: 50%;
left: 0px;
width: 100%;
height: 1px;
overflow: visible;
visibility: visible;
display: block
}
#content
{
position: absolute;
left: 50%;
width: 250px; /* Overall width of div */
height: 70px; /* Overall height of div */
top: -35px; /* half of the overall height */
margin-left: -125px; /* half of the overall width */
visibility: visible
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment