$embed-responsive-aspect-ratios: () !default;
// stylelint-disable-next-line scss/dollar-variable-default
-$embed-responsive-aspect-ratios: join(
+$embed-responsive-aspect-ratios: map-merge(
(
- (21 9),
- (16 9),
- (4 3),
- (1 1),
+ "21by9": (
+ x: 21,
+ y: 9
+ ),
+ "16by9": (
+ x: 16,
+ y: 9
+ ),
+ "4by3": (
+ x: 4,
+ y: 3
+ ),
+ "1by1": (
+ x: 1,
+ y: 1
+ )
),
$embed-responsive-aspect-ratios
);
}
}
-@each $embed-responsive-aspect-ratio in $embed-responsive-aspect-ratios {
- $embed-responsive-aspect-ratio-x: nth($embed-responsive-aspect-ratio, 1);
- $embed-responsive-aspect-ratio-y: nth($embed-responsive-aspect-ratio, 2);
-
- .embed-responsive-#{$embed-responsive-aspect-ratio-x}by#{$embed-responsive-aspect-ratio-y} {
+@each $key, $ratio in $embed-responsive-aspect-ratios {
+ .embed-responsive-#{$key} {
&::before {
- padding-top: percentage($embed-responsive-aspect-ratio-y / $embed-responsive-aspect-ratio-x);
+ padding-top: percentage(map-get($ratio, y) / map-get($ratio, x));
}
}
}
</div>
{{< /highlight >}}
-Within `_variables.scss`, you can change the aspect ratios you want to use. Here's an example of the `$embed-responsive-aspect-ratios` list:
+Within `_variables.scss`, you can change the aspect ratios you want to use. Here's an example of the `$embed-responsive-aspect-ratios` map:
{{< highlight scss >}}
$embed-responsive-aspect-ratios: (
- (21 9),
- (16 9),
- (4 3),
- (1 1)
-) !default;
+ "21by9": (
+ x: 21,
+ y: 9
+ ),
+ "16by9": (
+ x: 16,
+ y: 9
+ ),
+ "4by3": (
+ x: 4,
+ y: 3
+ ),
+ "1by1": (
+ x: 1,
+ y: 1
+ )
+);
{{< /highlight >}}