Created
September 17, 2013 14:30
-
-
Save kogakure/6595093 to your computer and use it in GitHub Desktop.
HTML/CSS: Intrinsic Ratios image solution for responsive images
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
<div class="img-container"> | |
<img src="http://cdn3.spiegel.de/images/image-545702-breitwandaufmacher-penw.jpg"> | |
</div> |
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-container { | |
background: red; | |
position: relative; | |
height: 0; | |
padding-bottom: 37.209302326%; /* 43:16 ratio */ | |
overflow: hidden; | |
} | |
.img-container img { | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100% | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment