Skip to content

Instantly share code, notes, and snippets.

@Farmatique
Last active March 3, 2017 18:46
Show Gist options
  • Save Farmatique/d6aa1fe9e5d6b15052ec17a9afa0cf6f to your computer and use it in GitHub Desktop.
Save Farmatique/d6aa1fe9e5d6b15052ec17a9afa0cf6f to your computer and use it in GitHub Desktop.
Center image <img> inside block
/* doesnt work on ios */
<div class="container">
<img />
</div>
.container{
width: 70px;
height: 70px;
-webkit-display: flex;
-moz-display: flex;
-ms-display: flex;
-o-display: flex;
display:-webkit-flex;
display: flex;
-webkit-align-items: center;
-moz-align-items: center;
-ms-align-items: center;
-o-align-items: center;
align-items: center;
-webkit-justify-content: center;
-moz-justify-content: center;
-ms-justify-content: center;
-o-justify-content: center;
justify-content: center;
}
.container img{
max-width: none; /* optional */
min-width: initial;
min-height: initial;
height: auto;
width: auto;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment