Skip to content

Instantly share code, notes, and snippets.

@onel0p3z
Created June 17, 2013 15:59
Show Gist options
  • Save onel0p3z/5798030 to your computer and use it in GitHub Desktop.
Save onel0p3z/5798030 to your computer and use it in GitHub Desktop.
How to REALLY center an HTML element (via CSS position absolute/fixed) from http://codepen.io/elad2412/pen/pkaIy
<html>
<body>
<style>
.popup{
position:fixed;
left:50%;
}
.popup .wrapper{
position:relative;
left:-50%;
/*popup-styles*/
background-color:#fff;
padding:10px;
border:solid 2px #444;
border-radius:10px;
}
html{background-color:#aaa;}
</style>
<div class="popup">
<div class="wrapper">
<img src="http://farm4.staticflickr.com/3721/8826906676_501192b1c4.jpg">
</div>
</div>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment