Created
March 18, 2017 16:38
-
-
Save sagarjadhav/50a0a2d40c05ae532b04e308102ead5c to your computer and use it in GitHub Desktop.
Css aspect ratio to have images of same height
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.img-parent img { | |
position: relative; | |
overflow: hidden; | |
padding-bottom: 69.44%; /* Calculated = height / width * 100 */ | |
display: block; | |
} | |
.img-parent img { | |
position: absolute; | |
top: 0; | |
bottom: 0; | |
left: 0; | |
right: 0; | |
margin: auto; | |
z-index: 0; | |
min-height: 100%; | |
width: auto; | |
max-width: none; | |
min-width: 100%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment