Last active
April 7, 2017 09:02
-
-
Save joewanko/e190352329ec693d932e to your computer and use it in GitHub Desktop.
SCSS Responsive height to width ratio trick.
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
.item { | |
background-attachment: inherit; | |
background-position: center; | |
background-size: cover; | |
display: inline-block; | |
height: auto; | |
position: relative; | |
width: 100%; | |
&::before { | |
content: ''; | |
display: block; | |
padding-top: 50%; // H / W * 100% (Fallback) | |
padding-top: calc(100 / 200 * 100%); // H / W * 100% | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment