AspectRatio class
The aspect-ratio CSS property allows you to define the desired width-to-height ratio of an element's
box. This means that even if the parent container or viewport size changes, the browser will adjust the
element's dimensions to maintain the specified width-to-height ratio.
Read more: MDN aspect-ratio
Constructors
- AspectRatio(int num, [int? denom])
-
Create an aspect ratio from the given numerator and optional denominator. The property is defined
as
num / denom. Ifdenomis omitted, it is assumed to be 1.constfactory - AspectRatio.autoOrRatio(int num, [int? denom])
-
Create an aspect ratio where
autoauto is used if the element is a replaced element with a natural aspect ratio, like anelement. Otherwise, the specified ratio of num / denom is used as the preferred aspect ratio.
constfactory
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- auto → const AspectRatio
- Replaced elements with an intrinsic aspect ratio use that aspect ratio, otherwise the box has no preferred aspect ratio. Size calculations involving intrinsic aspect ratio always work with the content box dimensions.
- inherit → const AspectRatio
- initial → const AspectRatio
- revert → const AspectRatio
- revertLayer → const AspectRatio
- unset → const AspectRatio