Layout

Aspect Ratio

A frame that keeps images, video and embeds at a fixed width-to-height ratio.

Class nameTypeDescription
aspect-ratioplf:aspect-ratioComponentA full-width frame, 16:9 by default
aspect-ratio-contentplf:aspect-ratio-contentPartThe image, video or iframe that fills the frame

Default

Give an informative image a meaningful alt.

Illustration of mountains surrounding a blue lake
Illustration of mountains surrounding a blue lake
Illustration of mountains surrounding a blue lake
Illustration of mountains surrounding a blue lake
Illustration of mountains surrounding a blue lake
cover
Illustration of mountains surrounding a blue lake
contain
Illustration of mountains surrounding a blue lake
fill
Illustration of mountains surrounding a blue lake
scale-down
Illustration of mountains surrounding a blue lake
none
Illustration of mountains surrounding a blue lake
cover, left

Video and embeds

An <iframe> takes aspect-ratio-content the same way and needs a title.

HTML
<div class="aspect-ratio">
  <video class="aspect-ratio-content" src="video.mp4" controls></video>
</div>

Inside a card

Beside a visible title, as in this Card, the image is decorative: give it alt="".

Card title

Card description.

React

AspectRatio from @pelatform/react renders this frame; your image, video or iframe in it takes aspect-ratio-content.

Prop Values Default
ratio A CSS ratio such as 4 / 3, or a number; it sets --plf-aspect-ratio 16 / 9

The other props are a div’s own, className and ref included; style takes the other variables, such as --plf-aspect-ratio-fit.

CSS variables

Override on a root or on a single frame; fit and position also work on the content element.

Variable Default
--plf-aspect-ratio 16 / 9; any CSS ratio
--plf-aspect-ratio-bg Muted surface
--plf-aspect-ratio-radius --plf-radius-lg, 0.5rem (8px)
--plf-aspect-ratio-fit cover; any object-fit value
--plf-aspect-ratio-position center; any object-position value

Built with Pelatform UIv0.1.0

Components

Getting started

Foundations

Components

Actions

Data display

Navigation

Feedback

Data input

Layout

Advanced

Integrations

Blocks

Application

Authentication

Icons