Skip to content

Instantly share code, notes, and snippets.

@juarezpaf
Created March 27, 2009 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juarezpaf/86485 to your computer and use it in GitHub Desktop.
Save juarezpaf/86485 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Centralizando elemento na tela</title>
<style type="text/css">
#center {
width: 100px;
height: 200px;
position: absolute;
top: 50%;
left: 50%;
margin: -50px 0 0 -100px; /*O truque é colocar essas margins negativas com metade da largura e altura*/
}
</style>
</head>
<body>
<div id="center">
Bla bla bla
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment