Created
October 11, 2011 15:49
-
-
Save barneycarroll/1278476 to your computer and use it in GitHub Desktop.
Keep a given aspect ratio for any content
This file contains 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
<style> | |
.aspectWrapper { | |
position: relative; | |
} | |
.aspectImg { | |
display: block; | |
height: auto; | |
position: relative; | |
width: 100%; | |
} | |
.aspectContent { | |
height: 100%; | |
left: 0; | |
position: absolute; | |
top: 0; | |
width: 100%; | |
} | |
</style> | |
<div class="aspectWrapper"> | |
<img class="aspectImg" src="5x4.blank.gif" alt /> | |
<div class="aspectContent"> | |
whatever | |
</div> | |
</dib> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment