Skip to content

Instantly share code, notes, and snippets.

@EastSideCode
Last active May 7, 2018 13:01
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 EastSideCode/f881dcdecc22db34351836ef4a8719bc to your computer and use it in GitHub Desktop.
Save EastSideCode/f881dcdecc22db34351836ef4a8719bc to your computer and use it in GitHub Desktop.
Vertical align floating images the easy way
.image-container {
height: 200px; /* can be whatever */
}
.image-container:before {
content: ' ';
display: inline-block;
vertical-align: middle;
height: 100%;
}
.image-container img {
width: 100%;
height: auto;
display: inline-block;
vertical-align: middle;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment