Ratios

All descendant elements of a ratio block (i.e. the items inside the ratio block) stretch to fill the shape of the ratio on all sides. So multiple items will stack on top of each other. With that in mind, it generally makes sense to include just one independent element inside a ratio block (e.g. a box, an image, a figure).

One exception is that if you include an image and a block of text, the image will behave like a background image.

Available Ratios

Currently ratios can be defined by number or by name, with mas many of the names as possible derived from the common name in general media for the size in question. The English naming approach might be reconsidered in the future, so although it is not yet deprecated, we encourage authors to use the ratio numbering system as the preferred way of implementing ratios.

  • ratio-3x21, ratio-column-thinner
  • ratio-4x21, ratio-column-thin
  • ratio-5x21, ratio-column
  • ratio-3x21, ratio-1x3, ratio-ultra-tall
  • ratio-9x21, ratio-panorama
  • ratio-1x2, ratio-double
  • ratio-9x16, ratio-tall
  • ratio-2x3, ratio-35mm-upright
  • ratio-3x4, ratio-portrait
  • ratio-1x1, ratio-square
  • ratio-4x3, ratio-landscape
  • ratio-3x2, ratio-35mm
  • ratio-16x9, ratio-wide
  • ratio-2x1, ratio-half
  • ratio-21x9, ratio-panorama
  • ratio-21x7, ratio-3x1, ratio-ultra-wide
  • ratio-21x5, ratio-banner
  • ratio-21x4, ratio-banner-thin
  • ratio-21x3, ratio-banner-thinner

Responsive Ratios

Like many other elements, ratios can be re-defined at each standard breakpoint. E.g. this collection of classes will define a landscape box that becomes square on small screens and tall on tiny screens:

ratio-4x3 ratio-1x1-small ratio-3x4-tiny

Ratios on Columns

One useful way to apply ratios is to columns in a columns block. (Note that the columns will lose their ratio if the .layout-grid class is applied, as all columns are equal height in a grid.)

Square 1x1

box bg-color-1 ratio-1x1 text-center

Rectangle 2x3

box bg-color-1 ratio-2x3 text-center

Rectangle 3x4

box bg-color-1 ratio-3x4 text-center

Rectangle 16x9

box bg-color-1 ratio-16x9 text-center

Ratios on Boxes

You'll get the same effect as ratios on columns by applying ratios to blocks within columns. but it involves creating extra block HTML tags. However then you can add multiple items to one column, and ratios will be maintained if the .layout-grid class is applied to the columns block.

Square 1x1

box bg-color-1 ratio-1x1 text-center

Rectangle 2x3

box bg-color-1 ratio-2x3 text-center

Rectangle 3x4

box bg-color-1 ratio-3x4 text-center

Rectangle 16x9

box bg-color-1 ratio-16x9 text-center

Rectangle 16x9

box bg-color-1 ratio-16x9 text-center

Ratios on Images

Original image

unsplash-jesse orrico

Images inside ratio blocks

By default images in a ratio block will "cover" the ratio space from the center outwards, meaning that one of the image dimensions (width or height) will touch both edges of the ratio block (left/right or top/bottom) and the other dimension will expand outward from the center as needed, cropping off parts of the image that don't fit into the box.

To do: In the near future we'll add the ability to position elements within the ratio blocks in different ways (top, bottom , left, right, center, etc.) but this isn't available yet. For now, it can be done in a non-responsive way using inline styles. Try adding 'style="object-position: left top;"' to the content within the ratio block.

Note: Earlier versions of Acora required adding "fill width" or "fill height" to certain images to make sure it covered the ratio space, but this is no longer required and in fact will produce a broken layout effect from 10.6.1 onwards. Existing content will need to be changed.

Ratios applied directly to image tags

Although from Acora 10.6.1 onwards it's possible to apply ratio classes directly to image tags and this is a simpler approach than using boxes, support for the aspect-ratio CSS attribute that is necessary for it to work has only very recently been added to some mobile browsers, and support is unknown in other mobile browsers. So for now, this  probably works but it's not guaranteed so it's not the recommended way of handling ratios. Also note this approach has not been fully tested for all content layout conditions.

Ratios on Images with Captions

To do: Images with captions are problematic when placed inside ratio divs in 10.6.1, this will be addressed in the future.

Caption
Caption
Image Caption
Caption
Image Caption
Caption

However it is still possible to define the ratio directly to the image tag using 10.6.1's experimental aspect ratio feature, which should work in all common browsers, and has a relatively non-breaking fallback in cases where it might not work - i.e. that the image will simply adopt its natural ratio.

Caption
Caption
Caption
But applying a ratio directly to the figure block does not work at the moment.

Using a Ratio Block with an Image as a Background

Items within a ratio block stack on top of each other, so generally it only makes sense to have one item in the block - e.g. an image, a figure, a box. However when adding an image to a ratio block and a block of content after it, the items stack to provide a useful background image effect.


Heading

You can put content in a box over an image.


Ratios on Cards and Postcards

Defining a ratio on cards and postcards collections is handled by defining the image ratio, since simply adding a ratio class would define the ratio of the block containing the cards, which is almost never useful.

Note: Although it's technically possible to define item-ratio and text-ratio independently from image-ratio, this wouldn't normally create a viable content layout.

Cards support responsive ratio definitions too.

cards postcards image-ratio-1x1 image-ratio-3x4-small