Last active
November 10, 2017 09:45
-
-
Save mvkasatkin/6046ecee72902db768758bd9bae45835 to your computer and use it in GitHub Desktop.
CSS3 responsive aspect ratio block
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
<div class="ratio" style="padding-top: 40%"> | |
<div class="ratio-content"> | |
This block is 40% ratio height | |
</div> | |
</div> |
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
.ratio { | |
/* set inline ratio padding-top in % */ | |
position: relative; | |
} | |
.ratio-content { | |
position: absolute; | |
top: 0; | |
left: 0; | |
right: 0; | |
bottom: 0; | |
overflow: hidden; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment