Last active
March 21, 2018 14:57
-
-
Save c0defre4k/9699b11263ca6df239be3962eb1d0e01 to your computer and use it in GitHub Desktop.
Variable ratios for responsive embeds
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
.embed-responsive-21by9::before { | |
padding-top: 42.85714%; | |
} | |
.embed-responsive-16by9::before { | |
padding-top: 56.25%; | |
} | |
.embed-responsive-4by3::before { | |
padding-top: 75%; | |
} | |
.embed-responsive-1by1::before { | |
padding-top: 100%; | |
} |
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
// ---- | |
// Sass (v3.4.21) | |
// Compass (v1.0.3) | |
// ---- | |
$embed-ratios: ( | |
21 9, | |
16 9, | |
4 3, | |
1 1 | |
) !default; | |
// generate embeds | |
@each $ratio in $embed-ratios { | |
.embed-responsive-#{nth($ratio, 1)}by#{nth($ratio, 2)} { | |
&::before { | |
padding-top: percentage(nth($ratio, 2) / nth($ratio, 1)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment