diff --git a/site/assets/scss/_component-examples.scss b/site/assets/scss/_component-examples.scss index 18b2c192e7..5ced393519 100644 --- a/site/assets/scss/_component-examples.scss +++ b/site/assets/scss/_component-examples.scss @@ -181,6 +181,15 @@ justify-content: center; } } +.bd-example-ratios-breakpoint { + .ratio-4x3 { + width: 16rem; + + @include media-breakpoint-up(md) { + --aspect-ratio: 50%; // 2x1 + } + } +} .bd-example-modal { background-color: #fafafa; diff --git a/site/content/docs/5.0/helpers/ratio.md b/site/content/docs/5.0/helpers/ratio.md index 10ea9bc39c..df24c1c604 100644 --- a/site/content/docs/5.0/helpers/ratio.md +++ b/site/content/docs/5.0/helpers/ratio.md @@ -55,6 +55,23 @@ For example, to create a 2x1 aspect ratio, set `--aspect-ratio: 50%` on the `.ra {{< /example >}} +This CSS variable makes it easy to modify the aspect ratio across breakpoints. The following is 4x3 to start, but changes to a custom 2x1 at the medium breakpoint. + +{{< highlight scss >}} +.ratio-4x3 { + @include media-breakpoint-up(md) { + --aspect-ratio: 50%; // 2x1 + } +} +{{< /highlight >}} + +{{< example class="bd-example-ratios bd-example-ratios-breakpoint" >}} +
+
4x3, then 2x1
+
+{{< /example >}} + + ## Sass map Within `_variables.scss`, you can change the aspect ratios you want to use. Here's our default `$ratio-aspect-ratios` map. Modify the map as you like and recompile your Sass to put them to use.