π Aspect ratio
The aspect ratio foundation allows you to define and maintain consistent proportions for elements (like images, videos, or containers) across multiple breakpoints. It automatically generates responsive classes using predefined ratio values and breakpoint rules. These classes follow the naming convention:
.f--ar-{ratio} // For all breakpoints.f--ar-{breakpoint}-{ratio} // For specific breakpoints
π How it works
Section titled βπ How it worksβThe media-sizes mixin loops through:
- A map of aspect ratios ($media-sizes)
- A map of breakpoints ($ar-breakpoints)
βοΈ Example ratio values ($media-sizes)
Section titled ββοΈ Example ratio values ($media-sizes)β$media-sizes: ( a: 1.77777777, // 16:9 b: 1.33333333, // 4:3 c: 1.5, // 3:2 d: 1, // 1:1 e: 0.75, // 3:4 f: 0.33333333 // 1:3);
π§ How to use it
Section titled βπ§ How to use itβIn HTML
<!-- Global 16:9 ratio --><div class="f--ar-a"></div>
<!-- 1:1 ratio applied only on tablets --><div class="f--ar-tabletm-d"></div>
In SCSS
- Extending the generated foundation class β preferred method:
.c--media-a { @extend .f--fr-a;}
- Using the mixin directly β only if strictly necessary:
.c--media-a { @include make-ar(map-get($media-sizes, a));}