The CSS transform origin is the point used when constructing an element's CSS transform matrix. The construction translates by the origin, applies the CSS transform functions, then translates by the negated origin. With homogeneous column vectors, its form is
where is the matrix product for the function list and translates by the origin .[ref]
For an own example, use an ordinary CSS box with a -by--pixel border box, transform-box: border-box, and no ancestor transforms. The declaration transform-origin: 50% 50% gives in local coordinates. With transform: scale(2), a point maps to
Thus maps to . The same point scaled about would instead map to .
The corresponding two-dimensional homogeneous matrix is
It maps the original corner to while leaving the center fixed. Changing the origin therefore changes the geometry even though the scale function is unchanged.
Percentages require a CSS transform reference box. A horizontal origin percentage uses that box's width and a vertical percentage its height; lengths provide offsets from its top-left corner. The reference-box selection and the point specified within it are two separate inputs.[ref]
The example explicitly chooses its box and origin instead of transferring defaults between ordinary CSS boxes and SVG elements. The transform origin is also distinct from the CSS scroll origin, which concerns the alignment of scrollable contents. One governs coordinate transformation; the other anchors scrolling geometry.

Articles by others on the same topic (0)

There are currently no matching articles.