Skip to content

Instantly share code, notes, and snippets.

@markvital
Created November 24, 2012 06:22
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 markvital/4138645 to your computer and use it in GitHub Desktop.
Save markvital/4138645 to your computer and use it in GitHub Desktop.
Another way to center div in position:absolute CSS
<html>
<head><title> Centered content</title></head>
<body>
<div style="position: absolute; left: 50%;">
<div style="position: relative; left: -50%; border: dotted red 1px;">
I am some centered shrink-to-fit content! <br />
tum te tum
</div>
</div>
</body>
</html>
<!-- insipred by http://stackoverflow.com/a/1777282 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment