Last active
November 18, 2017 11:57
-
-
Save andregoncalves/f37d0dc34b045a07e1f2f526fe538af7 to your computer and use it in GitHub Desktop.
CSS maintain block aspect ratio
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
<style> | |
.aspect-ratio { | |
padding-top: calc(1 / (16 / 9) * 100%); | |
position : relative; | |
} | |
.aspect-wrapper { | |
position: absolute; | |
top:0; | |
left:0; | |
width:100%; | |
height:100%; | |
} | |
</style> | |
<div class="aspect-ratio"> | |
<div class="aspect-wrapper"> | |
Maintains block aspect ratio at different resolutions | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment