Changes to zero and near-zero values of perspective

Skip to first unread message

David Baron

Jun 4, 2021, 11:24:17 AM6/4/21
to blink-dev
I’m planning to submit some changes to the handling of zero and near-zero (less than 1px) values of the perspective property and the perspective() function in the transform property, on the basis of a CSS Working Group resolution that was made for good reasons.  There’s some risk of broken Web content as a result, so I’m sending this email.

For more details on what’s changing and why the change is the right thing, see the change’s description.  The summary of the new behavior is that values 0 and larger are accepted syntax, but any values smaller than 1px will be clamped to a minimum of 1px.

The main risk for content breakage is with zero values.  It’s possible that content is currently using perspective: 0 or transform: perspective(0) and expecting it to do nothing (either because it produced the identity matrix or because it was syntactically invalid).  This will change that behavior and cause it to apply a relatively drastic transformation (the one currently applied by perspective: 1px or transform: perspective(1px)).  If any sites are broken as a result, they should likely be able to fix the breakage by using perspective: none (instead of 0) or by removing the perspective(0) from the transform list or replacing it with a transform that is the identity function (e.g., scale(1), translateX(0), translateZ(0)).

As brief background, since perspective can be confusing, the perspective() function for transform, and the perspective property (which applies a similar effect as the function, but to the element’s children) are part of CSS 3D transforms, and create the appearance of perspective by enlarging content that’s closer to the viewer (positive z coordinate) and shrinking content that is farther (negative z coordinate).  perspective(infinity) is the identity transform, and perspective(small number) means that content with positive z coordinates becomes very large, and negative z coordinates becomes very small (because the viewer is “very close”).

Reply all
Reply to author
0 new messages