Skip to content

Instantly share code, notes, and snippets.

@kfiil
Last active August 29, 2015 14:00
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 kfiil/cfbd2ecfafd47086ef4c to your computer and use it in GitHub Desktop.
Save kfiil/cfbd2ecfafd47086ef4c to your computer and use it in GitHub Desktop.
Vertically align an image inside div
/*
Source http://stackoverflow.com/a/7310398
http://jsfiddle.net/kizu/4RPFa/74/
*/
.frame {
height: 25px; /* equals max image height */
width: 160px;
border: 1px solid red;
text-align: center; margin: 1em 0;
}
.helper {
display: inline-block;
height: 100%;
vertical-align: middle;
}
img {
background: #3A6F9A;
vertical-align: middle;
max-height: 25px;
max-width: 160px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment