fitContain
Places content in a box, as large as possible while staying entirely inside the box (CSS object-fit: contain). Shortcut for fit(content, box, { mode: 'contain', align }).
Available since v3.1.5
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
content | Size | The size of the content |
box | Size | The size of the box |
align | FitAlign | Where to place it, centered by default — see FitAlign (optional) |
Returns
Section titled “Returns”Matrix — The content-to-box matrix (a/d scales, e/f position)
Examples
Section titled “Examples”Centered
Section titled “Centered”Same as fit(content, box, { mode: ‘contain’ }).
Aligned to the top-left corner
Section titled “Aligned to the top-left corner”The third argument is the alignment, like CSS object-position.
Related Types
Section titled “Related Types”FitAlign
Section titled “FitAlign”Where fit places content in the space left over (or overflowing), as CSS
object-position: 0 is left / top, 0.5 centered, 1 right / bottom.
Matrix
Section titled “Matrix”A 2D affine transformation, in the layout of CSS and SVG matrix(a, b, c, d, e, f):
A width and a height.
