-
Notifications
You must be signed in to change notification settings - Fork 756
Description
Previous discussion
Back in 2012 there was a discussion about extending the transform-origin property to take a list of origins and make transform comma-separated.
I'd like to reconsider this, because I think its a common use case to have different origins for transformations and I couldn't find a final conclusion on this.
The suggestions in that thread were:
- Let
transform-originandtransformtake comma-separated lists like e.g. thebackground-*properties. - Introduce a
origin()function affecting all following transformations - Extend the transform functions by parameters for the origin.
Arguments against the different solutions above were:
- SVG allows both, comma and space separation (SVG 2 refers to CSS Transforms, so the syntax is the same)
- backwards incompatible
- cannot be overridden partially
- more verbose for the average case
- confusion-prone
- inconsistent with how other properties work (obviously wrong, as other properties use commas for list separation)
- comma-separating all transform functions complicates adding a list of transform functions
Proposal
Considering the above, my idea is the following:
-
Introduce a
transform-functionlonghand property, which takes a comma-separated list of multiple space-separated transform functionsThe syntax of
transform-functionwould look like this:none | <transform-function-list>#where
<transform-function-list> = <transform-function>+ -
Change
transform-originto take a comma-separated list of transform originsThe syntax of
transform-originwould then look like this:<transform-origin>#where
<transform-origin> = [ left | center | right | top | bottom | <length-percentage> ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ] <length>? | [[ center | left | right ] && [ center | top | bottom ]] <length>?(or maybe just
<position>)Each would default to
50% 50%. -
Turn
transforminto a shorthand fortransform-functionandtransform-originThe syntax of
transformwould then look like this:[ <transform-function-list> <transform-origin>? ]#
This would be backwards compatible, make them consistent with other properties like background-*, avoid confusion and allow to set different origins for the transform functions.
Example
transform: rotate(20deg) skew(10deg, 5deg) 0 0, scale(80%)This would rotate the element by 20 degrees around the upper-left corner, then skew it by 10 degrees on the X axis and 5 degrees on the Y axis, and finally scale it around the center by 80 percent.
Sebastian