]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Allow to add more embed responsive ratios (#25894)
authorMartijn Cuppens <martijn.cuppens@gmail.com>
Sun, 11 Nov 2018 09:04:04 +0000 (10:04 +0100)
committerXhmikosR <xhmikosr@gmail.com>
Sun, 11 Nov 2018 09:04:04 +0000 (11:04 +0200)
scss/_variables.scss
scss/utilities/_embed.scss
site/docs/4.1/utilities/embed.md

index e721c2a65bd5893a4af879a76bde120767866b6a..dac260c1970885ea7a87eec443cee0963668e1aa 100644 (file)
@@ -259,6 +259,17 @@ $transition-base:             all .2s ease-in-out !default;
 $transition-fade:             opacity .15s linear !default;
 $transition-collapse:         height .35s ease !default;
 
+$embed-responsive-aspect-ratios: () !default;
+// stylelint-disable-next-line scss/dollar-variable-default
+$embed-responsive-aspect-ratios: join(
+  (
+    (21 9),
+    (16 9),
+    (3 4),
+    (1 1),
+  ),
+  $embed-responsive-aspect-ratios
+);
 
 // Fonts
 //
index d3362b6fdb19fff6c8d5998ceefdb41c7538eb5c..4497ac0400fbfacc098868f93fb1d55bf3d2ac77 100644 (file)
   }
 }
 
-.embed-responsive-21by9 {
-  &::before {
-    padding-top: percentage(9 / 21);
-  }
-}
-
-.embed-responsive-16by9 {
-  &::before {
-    padding-top: percentage(9 / 16);
-  }
-}
-
-.embed-responsive-4by3 {
-  &::before {
-    padding-top: percentage(3 / 4);
-  }
-}
+@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-1by1 {
-  &::before {
-    padding-top: percentage(1 / 1);
+  .embed-responsive-#{$embed-responsive-aspect-ratio-x}by#{$embed-responsive-aspect-ratio-y} {
+    &::before {
+      padding-top: percentage($embed-responsive-aspect-ratio-y / $embed-responsive-aspect-ratio-x);
+    }
   }
 }
index 4713c598c9dffd131185c9dae099b68066011785..de4105fb8267f9c32c40d0b46a329afe255cdf6f 100644 (file)
@@ -25,7 +25,7 @@ Wrap any embed like an `<iframe>` in a parent element with `.embed-responsive` a
 
 ## Aspect ratios
 
-Aspect ratios can be customized with modifier classes.
+Aspect ratios can be customized with modifier classes. By default the following ratio classes are provided:
 
 {% highlight html %}
 <!-- 21:9 aspect ratio -->
@@ -48,3 +48,14 @@ Aspect ratios can be customized with modifier classes.
   <iframe class="embed-responsive-item" src="..."></iframe>
 </div>
 {% endhighlight %}
+
+Within `_variables.scss`, you can change the aspect ratios you want to use. Here's an example of the `$embed-responsive-aspect-ratios` list:
+
+{% highlight scss %}
+$embed-responsive-aspect-ratios: (
+  (21 9),
+  (16 9),
+  (3 4),
+  (1 1)
+) !default;
+{% endhighlight %}