Skip to content

Instantly share code, notes, and snippets.

@ladas-larry
Last active August 13, 2017 09:59
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 ladas-larry/2f691121d6c31707cf0b874495a1257c to your computer and use it in GitHub Desktop.
Save ladas-larry/2f691121d6c31707cf0b874495a1257c to your computer and use it in GitHub Desktop.
CSS
Centering in the Unknown
/* Vertically centering an element of known dimensions inside an element of unknown dimensions */
/* image width and height is 24px. Plus 10px padding it comes to 34px. 17px is half of this width and height */
.centeredIcon {
padding: 5px;
position: absolute;
top: calc(50% - 17px);
left: calc(50% - 17px);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment