Skip to content

Instantly share code, notes, and snippets.

@ladas-larry ladas-larry/tricks.css
Last active Aug 13, 2017

What would you like to do?
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
You can’t perform that action at this time.