Skip to content

Instantly share code, notes, and snippets.

@mediamichael
Created November 22, 2014 15:39
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 mediamichael/ada170c100f4987d22f5 to your computer and use it in GitHub Desktop.
Save mediamichael/ada170c100f4987d22f5 to your computer and use it in GitHub Desktop.
// http://www.smashingmagazine.com/2013/08/09/absolute-horizontal-vertical-centering-css
// center
.Absolute-Center {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
// within container
.Center-Container {
position: relative;
}
.Absolute-Center {
width: 50%;
height: 50%;
overflow: auto;
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
// within viewport
.Absolute-Center.is-Fixed {
position: fixed;
z-index: 999;
}
// offsets
.Absolute-Center.is-Right {
left: auto; right: 20px;
text-align: right;
}
.Absolute-Center.is-Left {
right: auto; left: 20px;
text-align: left;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment