Skip to content

Instantly share code, notes, and snippets.

@kublaj
Forked from jhafner/absolute-centering.css
Created May 31, 2016 10:56
Show Gist options
  • Save kublaj/70e08ffc476f3050c19cd43bad482b6e to your computer and use it in GitHub Desktop.
Save kublaj/70e08ffc476f3050c19cd43bad482b6e to your computer and use it in GitHub Desktop.
Absolute centering of elements with CSS. Advantages: Cross-browser (including IE8-10) No special markup, minimal styles Responsive with percentages and min-/max- Use one class to center any content Centered regardless of padding (without box-sizing!) Blocks can easily be resized Works great on images Caveats: Height must be declared Recommend se…
.Center-Container {
position: relative;
}
.Absolute-Center {
width: 50%;
height: 50%;
overflow: auto;
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment