Skip to content

Instantly share code, notes, and snippets.

@rcerrejon
Created February 11, 2016 11:30
Show Gist options
  • Save rcerrejon/e0c501118267dc73a38d to your computer and use it in GitHub Desktop.
Save rcerrejon/e0c501118267dc73a38d to your computer and use it in GitHub Desktop.
Background absolute center horizontal and vertical
/* CSS in order to center an element (with position absolute) in a container: */
.centeredIcon {
background: url("http://www.google.com/favicon.ico") no-repeat transparent;
width:64px;
height:64px;
position:absolute;
left:50%;
top:50%;
margin-left:-32px; /* half of the width */
margin-top:-32px; /* half of the height */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment