MDN self-hosted library · e01.org
Aspect ratio / notebook

Aspect ratio

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

css
.wideBox {
  aspect-ratio: 5 / 2;
}
.tallBox {
  aspect-ratio: 0.25;
}
html
<svg viewBox="0 0 300 100" xmlns="http://www.w3.org/2000/svg"></svg>
js
const constraints = {
  width: 1920,
  height: 1080,
  aspectRatio: 1.777777778,
};

myTrack.applyConstraints(constraints);