Last active
February 8, 2018 12:01
-
-
Save iksi/89d4c9a21a74798b9ece8540bc8d9826 to your computer and use it in GitHub Desktop.
maintain ratio with svg (hack)
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> | |
.embed { | |
position: relative; | |
} | |
.embed__ratio { | |
display: block | |
} | |
.embed__content { | |
bottom: 0; | |
left: 0; | |
position: absolute; | |
right: 0; | |
top: 0; | |
} | |
</style> | |
<div class="embed"> | |
<svg class="embed__ratio" viewbox="0 0 4 3" display="none"></svg> | |
<img class="embed__content" src="broken.jpg" alt> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
simpler way of maintaining ratio without using inline styles. the svg initially has
display="none"
purely to hide it when no stylesheet gets loaded.