Aspect Ratio
A full-width box that keeps a set width-to-height ratio, for images and video.
Installation
Usage
src/app/app.ts
- The box is as wide as its parent. Its height follows from
ratio, which is width divided by height. - Content that spills past the box is clipped (
overflow-hidden). - There's no automatic ratio from the image's own size. Lynx supports only explicit
aspect-ratiovalues. - Set
modeon the<image>. CSSobject-fitdoesn't work on Lynx.
Common ratios
The default 1 makes a square. 9 / 16 makes a tall box for portrait video.
Narrower than the parent
A width class replaces the default w-full, and the height follows.
API
UiAspectRatio
No outputs.
